【发布时间】:2014-02-21 01:16:49
【问题描述】:
我正在尝试从一个空间文件夹中导入一个 .CSV 文件以供访问。
我通过导入第一个 CSV 文件设置了自己的导入规范。然后我写了这段代码
Sub ImportCSVFiles()
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String
Dim blnHasFieldNames As Boolean
Const IMPORT_SPEC = "Megger Readings Import Specification"
' Change this next line to True if the first row in EXCEL worksheet
' has field names
blnHasFieldNames = True
' Replace C:\Documents\ with the real path to the folder that
' contains the csv files
strPath = "C:\Users\arbmaint\Desktop\Jumbo start loading test results"
' Replace tablename with the real name of the table into which
' the data are to be imported
strTable = "Test Results"
strFile = Dir(strPath & "*.csv")
Do While Len(strFile) > 0
strPathFile = strPath & strFile
DoCmd.TransferText acImportDelim, "Megger Readings Import Specification", strTable, strPathFile, blnHasFieldNames
Kill strPathFile
strFile = Dir()
Loop
End Sub
然后我连接了一个按钮来运行此命令,即使它符合要求,也没有任何反应。
任何帮助都会很棒。
【问题讨论】:
标签: ms-access csv ms-access-2007 vba