Bir Tam Yolun Olup Olmadığını Öğren - Microsoft Excel


Verilen tam yolun (dosya veya klasör) olup olmadığını kontrol etmeye yarayan VBA kodu alternatifidir.

Kod


Option Explicit

'--------------------------------------------------
'Fonksiyon
'--------------------------------------------------
Private Function TamYolunOlupOlmadiginiOgren(tamYol As String) As Boolean
    Dim x As String
    
    On Error Resume Next
    
    x = GetAttr(tamYol) And 0
    
    If Err = 0 Then
        YolVarMi = True
    Else
        YolVarMi = False
    End If
End Function

'--------------------------------------------------
'Kullanım Örneği
'--------------------------------------------------
Sub OrnekKullanim()
    Dim sonuc As Boolean
    
    sonuc = YolVarMi("C:\")
    
    If (sonuc = True) Then
        MsgBox "Yol mevcut."
    Else
        MsgBox "Yol mevcut değil."
    End If
End Sub

Etiketler
microsoft excel microsoft excel vba microsoft excel vba dosya klasör işlemleri microsoft excel vba kullanıcı tanımlı fonksiyon işlemleri