最も簡単な答えはありません、あなたが、何らかの形でのエラーで使用しますと予想されます、次のいずれかです。
On error resume next
Workbooks.Open("C:\Users\Desktop\Test\journals.xlsx")
If Err.Number <> 0 then
' the workbook is not at that location
Err.Clear
On Error Goto 0
End If
かで
従来のエラーハンドラ:
errhandler:
If Err.Number <> 0 then
If Err.Number = 1004 Then
' the workbook is not at that location, do something about it, then resume next
End If
End If
ただし、ファイルが存在するかどうかをテストするFileSystemObjectを使用することができます:[VBAエラー処理のために良いパターン]の
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
fileExists = fso.fileExists("C:\Users\Desktop\Test\journals.xlsx")
可能な複製(http://stackoverflow.com/questions/1038006/good-patterns- for-vba-error-handling) – vacip
On Errorステートメントなしで解決したいと思っていました。 – Vinnie
VBAでのエラー処理は、On Errorステートメントで行われます。期間。場合によっては、問題の特定の解決策を見つけることができます。誤解を招く可能性があるため、タイトルを変更する必要があるかもしれません。これはエラー処理ではなく、ファイルが存在するかどうかを確認することです。 (どちらの質問にもここに10000答えがあります...) – vacip