0
我想从一个文件夹中导入一个.CSV文件进行访问。VB代码不工作.CSV导入访问2007
我已经通过导入第一个CSV文件设置了自己的导入规格。然后我writen这个代码
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
我再连接一个按钮向上运行此命令,即使它符合还好没有任何反应。
任何帮助将是伟大的。