0
我有2個文件夾TEXTFILES & excelFiles,它們具有相同的文件名,但具有不同的擴展名(TEXTFILES = .TXT & excelFiles = .xlsx)格式, 我寫代碼,以查找文本文件中的文件是否在excelFiles中不存在以調用創建它的函數。VBA比較兩個文件夾,找到文件型動物
Sub LookForNew()
Dim dTxt As String
Set fso = CreateObject("Scripting.FileSystemObject")
Set filsTxt = fso.GetFolder("C:\txtFiles").Files
Set filsExcel = fso.GetFolder("C:\excelFiles").Files
Set oFileExcel = CreateObject("Scripting.Dictionary")
Set tFileExl = CreateObject("Scripting.Dictionary")
Set oFileExl = CreateObject("Scripting.Dictionary")
For Each fil In filsTxt
dTxt = fil.Name
For Each exl In filsExcel
oFileExcel = exl.Name
oFileExl = Split(oFileExcel, ".")
tFileExl = oFileExl(0)
Next exl
If Not (tFileExl.Exists(dTxt)) Then
' Call function
Else
MsgBox "No more files to convert"
End If
Next fil
Set fso = Nothing
末次
但在我的代碼不會返回一個字典,而是一字符串 幫助PLZ