標題:
請問 Application.FileSearch '執行階段錯誤2455 ,請問這應該怎麼修改?
[打印本頁]
作者:
HSIEN6001
時間:
2019-11-1 05:18
標題:
請問 Application.FileSearch '執行階段錯誤2455 ,請問這應該怎麼修改?
Function 資訊()
DoCmd.SetWarnings False
Dim Filename As Integer
Set BK = Application.FileSearch '執行階段錯誤2455 ,請問這該怎麼改?
With BK
.LookIn = "D:\資訊-原始\"
.Filename = "all*.xls"
If .Execute(SortBy:=msoSortByFileName, SortOrder:=msoSortOrderAscending) > 0 Then
For B = 1 To .FoundFiles.Count
DoCmd.TransferSpreadsheet acImport, 8, "00 原始資料", .FoundFiles(B), True
Next
End If
End With
Set BK = Nothing
End Function
複製代碼
作者:
cody
時間:
2020-7-18 16:56
請問 office 版本?, 可以換 FileSystemObject 來用
Dim FSO As Object
Dim localfolder As String
Set FSO = CreateObject("Scripting.FileSystemObject")
localfolder = "D:\資訊-原始\"
Set fld = FSO.GetFolder(localfolder)
For Each myFileName In fld.Files
If FSO.GetExtensionName(localfolder & myFileName.Name) = "xls" Then
Debug.Print myFileName.Name
End If
Next
複製代碼
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)