5
我正在嘗試重寫一些使用FileSearch for Excel 2003 VBA的代碼。我試圖調用一個應該確定1或0的函數,並使用If
語句,我將執行一些代碼或迭代到下一個文件。如何確定文件是否存在使用VBA Excel 2007?
我沒有從我的函數返回正確的結果。
我的代碼:
Dim MyDir As String, Fn As String
Dim MyFile As String
MyDir = "C:Test\"
Fn = "" & "" & Examiner & " " & MnName & " " & Yr & ".xls"
MyFile = MyDir & """" & Fn & """"
If FileThere(MyFile) Then
MsgBox yes
Else
MsgBox Not there
End If
'''''''''''''''''
Function FileThere(FileName As String) As Boolean
FileThere = (Dir(FileName) > "")
End Function
非常感謝你。 – JohnM 2010-11-03 16:05:20