问题描述
我有很多名称为oilcleared_oil_yyyy_mm_dd.csv的csv文件。我希望能够将它们导入到我称为Access1的访问表中。该表包含以下列。
我希望用户导入要导入文件的日期,但是,正如您从csv中看到的那样,需要排除前两个rwo,并将csv中的列映射到表列。
到目前为止,我有以下帮助,将不胜感激。
Sub csv_import()
Dim DATE1 As String
Dim PATH As String
Msg = "Enter Date as dd/mm/yyyy"
UserEntry = InputBox(Msg)
If UserEntry = "" Then Exit Sub
If IsDate(UserEntry) Then
DATE1 = Format(UserEntry,"yyyy_mm_dd")
Else
Msg = "Please try again. Enter date as dd/mm/yyyy"
End If
'DATE1 = Format(Date,"yyyy_mm_dd")
PATH = "C:\Users\icecleared_oil_" & DATE1 & ".csv"
On Error GoTo Bad
DoCmd.TransferText acImportDelim,"Import-icecleared_oil","Sheet1",PATH,True
Exit Sub
Bad:
MsgBox "The File for the date " & DATE1 & " cannot be found in the directory " & PATH & " OR the file
is currently opened by another user"
End Sub
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)