2010-05-18 52 views

回答

1
If Dir("file_location_1") <> "" Then 
    ''# File is in 1 
ElseIf Dir("file_location_2") <> "" Then 
    ''# File is in 2 
ElseIf Dir("file_location_3") <> "" Then 
    ''# File is in 3 
Else 
    ''# File is not found 
End If 

三年多的可能位置的数组和For循环将是更好的解决方案。

+0

我的文件名可能是9424.bas或9424a.esy或9424_.bas或9424 ... esy,我知道文件名是什么,但我知道重要的字符9424 – 2010-05-18 20:07:56

1
Dim fso 
Set fso = CreateObject("Scripting.FileSystemObject") 

If fso.FileExists("folder1" + "filename") then 
    ' folder1 
ElseIf fso.FileExists("folder2" + "filename") then 
    ' folder2 
ElseIf fso.FileExists("folder3" + "filename") then 
    ' folder3 
End If