Sub LoadTxtToACC()
Dim oMyacc As New Access.Application
Dim WorkPath As String
Set oTmpfs = CreateObject("Scripting.FileSystemObject")
Application.ScreenUpdating = False
WorkPath = ThisWorkbook.Path & "/"
Workbooks.OpenText Filename:=WorkPath & "应收.txt", DataType:=xlDelimited, _
Other:=True, OtherChar:="│", FieldInfo:=Array(Array(1, 9), Array(4, 5), Array(5, 5))
Columns(6).TextToColumns DataType:=xlDelimited, Other:=True, OtherChar:=":"
For i = 1 To 7
Cells(1, i) = Choose(i, "i_info_no", "zt", "ys_date", "ss_date", "premium", "id", "name")
Next
ActiveWorkbook.SaveAs Filename:=WorkPath & "应收.xls", FileFormat:=xlNormal
ActiveWorkbook.Close
With oMyacc
.OpenCurrentDatabase WorkPath & "aaa.mdb"
.DoCmd.TransferSpreadsheet , , "应收", WorkPath & "应收.xls", True
.CloseCurrentDatabase
End With
Set oMyacc = Nothing
oTmpfs.deletefile WorkPath & "应收.xls"
Application.ScreenUpdating = True
MsgBox "文本数据导入ACCESS完毕!"
End Sub
Dim oMyacc As New Access.Application
Dim WorkPath As String
Set oTmpfs = CreateObject("Scripting.FileSystemObject")
Application.ScreenUpdating = False
WorkPath = ThisWorkbook.Path & "/"
Workbooks.OpenText Filename:=WorkPath & "应收.txt", DataType:=xlDelimited, _
Other:=True, OtherChar:="│", FieldInfo:=Array(Array(1, 9), Array(4, 5), Array(5, 5))
Columns(6).TextToColumns DataType:=xlDelimited, Other:=True, OtherChar:=":"
For i = 1 To 7
Cells(1, i) = Choose(i, "i_info_no", "zt", "ys_date", "ss_date", "premium", "id", "name")
Next
ActiveWorkbook.SaveAs Filename:=WorkPath & "应收.xls", FileFormat:=xlNormal
ActiveWorkbook.Close
With oMyacc
.OpenCurrentDatabase WorkPath & "aaa.mdb"
.DoCmd.TransferSpreadsheet , , "应收", WorkPath & "应收.xls", True
.CloseCurrentDatabase
End With
Set oMyacc = Nothing
oTmpfs.deletefile WorkPath & "应收.xls"
Application.ScreenUpdating = True
MsgBox "文本数据导入ACCESS完毕!"
End Sub