我的代码有问题 - 我需要它多次导入数据,但我需要先将数据正确编辑到分隔列中。
基本上,当我踏入它时,程序可以一次性完成文本列。但在那之后,即使这些文本文件的格式都相同,它也无法转换。
示例数据 - 如您所见,这些具有分隔符(= 和 ,)
"7",="AR",="",="",="720325438",="491.45",="0.00",="0.00",="0.00",="0.00"
"7",="AR",="",="",="720344843",="40.00",="0.00",="0.00",="0.00",="0.00"
代码:
Dim xlApp As Excel.Application
Dim xlSheet As Excel.Worksheet
For intCurrentfileNumber = 1 To intNumOfFiles
strCurrentFolderName = varFileArray(intCurrentfileNumber, 0)
strCurrentFileName = varFileArray(intCurrentfileNumber, 1)
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Workbooks.Open strCurrentFolderName & "\" & strCurrentFileName
Set xlSheet = xlApp.Worksheets(1)
xlSheet.("A1", Range("A" & Rows.Count).End(xlUp)).TextToColumns _
Destination:=Range("A1"), _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=True, _
Tab:=False, _
Semicolon:=False, _
Comma:=True, _
Space:=False, _
Other:=True, _
OtherChar:="=", _
TrailingMinusNumbers:=True
ActiveWorkbook.Close (True)
xlApp.Quit
Set xlApp = Nothing
Set xlSheet = Nothing
DoCmd.TransferText acImportDelim, "Import Specification", "Staging", strCurrentFolderName & "\" & strCurrentFileName, True
Next intCurrentFileNumber