vba校验文件是否存在

Dim fso As FileSystemObject
Set fso = New FileSystemObject

  If Not fso.FileExists(sPath & sFile) Then
  If bRetry Then
  Beep
  If MsgBox("File, " + sPath + sFile + " , not found!", vbCritical + vbRetryCancel, "File Access Error") = vbCancel Then
    Exit Function
  Else
    GoTo Research
    End If
  End If
Else
  FileExist = True
End If

 

posted @ 2023-03-23 10:17  vba是最好的语言  阅读(42)  评论(0编辑  收藏  举报