Saturday, April 20, 2019

Check if Folder Exists using Excel VBA

Check if Folder Exists using Excel VBA


'In this Example I am checking if "C:\Temp" exits
Sub sbCheckingIfAFolderExists()

Dim FSO
Dim sFolder As String

sFolder = "C:\Temp" ' You can Specify Any Folder To Check It
Set FSO = CreateObject("Scripting.FileSystemObject")

If FSO.FolderExists(sFolder) Then
MsgBox "Specified Folder Is Available", vbInformation, "Exists!"
Else
MsgBox folder &"Specified Folder Not Found", vbInformation, "Not Found!"
End If

End Sub

No comments:

Post a Comment