我需要帮助打开上次修改后的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
答案 0 :(得分:0)
你不应该在变量周围加上引号,这会使它们成为字符串:
DoCmd.TransferText acImportDelim, "", "Tablename", Availability, True, ""
您要导入最旧的文件,因为您说的是myDate < temp
我会在整个过程中使用FileSystemObject。