0
こんにちは私はAccessに配置した次のコードを完成させるためにいくつかの助けが必要です。私はディレクトリ内のすべてのExcelファイルを反復する方法でファイル変数に一致するように、mfile変数に関するコードを変更する際の提案を探しています。2番目の変数の反復を最初にリンクする
Public Function load_data()
'mfile is modified filename with "xl" prefix to group all imported tables
together
Dim file, mfile As Variant
file = Dir(CurrentProject.Path & "\")
mfile = "xl_" & Left(file, Len(file) - 5)
Do Until file = ""
Debug.Print mfile
If file Like "*.xlsx" Then
For Each tbl In CurrentDb.TableDefs
If mfile = tbl.Name Then
DoCmd.DeleteObject acTable, tbl.Name
Exit For
End If
Next tbl
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, mfile, CurrentProject.Path & "\" & file, True
End If
file = Dir
Loop
End Function
これは簡単です。ありがとう。私はそれを思い描いていた。 – BarryMahnly