我收到3011错误,即使它能找到对象

时间:2013-12-26 08:00:56

标签: access-vba

有人可以帮我吗?似乎访问能够获取对象。然而,它以某种方式表明它无法找到它。怎么了?谢谢

Private Sub bImportFiles_Click()
On Error GoTo bImportFiles_Click_Err

Dim objFS As Object, objFolder As Object
Dim objFiles As Object, objF1 As Object
Dim strFolderPath As String

strFolderPath = "C:\Documents\HS\"
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(strFolderPath)
Set objFiles = objFolder.files

For Each objF1 In objFiles
If Right(objF1.Name, 3) = "txt" Then
DoCmd.TransferText acImportDelim, "HS Import Specification", "tblHS", strFolderPath &    objF1.Name, True
End If
Next

Set objF1 = Nothing
Set objFiles = Nothing
Set objFolder = Nothing
Set objFS = Nothing

bImportFiles_Click_Exit:
Exit Sub

bImportFiles_Click_Err:
MsgBox Err.Number & " " & Err.Description
Resume bImportFiles_Click_Exit
End Sub

1 个答案:

答案 0 :(得分:1)

Access不喜欢文件名中的点(。)。尝试将(。)替换为(_) 'HS_2011_01_01 text.txt'