我需要帮助在访问中打开最后修改的 csv。CSV 文件位于某个文件夹 FF 中。我在下面有一些代码,但错误是在将选择的 csv 文件导入访问中 任何人都可以用这一行想到: DoCmd.TransferText acImportDelim, "", "Tablename", "Availability", True, ""
Private Sub Import_Click()
Dim myDir As String, fn As String, a(), n As Long, Availability As String
Dim myDate As Date, temp As Date
myDir = "C:\Documents and Settings\FF"
fn = Dir(myDir & "\*.csv")
Do While fn <> ""
temp = CreateObject("Scripting.FileSystemObject").GetFile(myDir & "\" & fn).DateLastModified
If myDate = 0 Then
myDate = temp: Availability = myDir & "\" & fn
Else
If myDate < temp Then myDate = temp: Availability = myDir & "\" & fn
End If
fn = Dir
Loop
If Len(Availability) Then
If vbYes = MsgBox("Opening Availability File Name : " & Availability & vbLf & _
"Last modified on : " & myDate, vbYesNo) Then
DoCmd.TransferText acImportDelim, "", "Tablename", "Availability", True, ""
End If
End If