Tam yolu verilen bir dosyanın mevcut olup olmadığını gösteren VBA kodu alternatifidir.
Option Explicit
Sub BirDosyaninOlupOlmadiginiOgren()
Dim fileSystemObject As Object
Dim dosyaKontrol As Boolean
Set fileSystemObject = CreateObject("Scripting.FileSystemObject")
dosyaKontrol = fileSystemObject.FileExists( _
"C:\OrnekKlasor\CalismaKitabi2.xlsx")
If dosyaKontrol = True Then
MsgBox "Dosya bulundu.", vbOKOnly
Else
MsgBox "Dosya bulunamadı.", vbCritical
End If
End Sub