Saturday, October 31, 2015

How to Check and Create a Folder in VBA

How to Check whether a Folder Exists or Not in a Specific Path
Suppose If we want to Create a Folder with Name as "TestFolder" only if it does not exist in the Specified Path , we can use the Len function along with the IF Condition to check the Folder existence then we use the MkDir keyword to create a folder as per below

If Len(Dir("C:\Users\Tamatam\Desktop\Reports\TestFolder", vbDirectory)) = 0 Then
   
   MkDir "C:\Users\Tamatam\Desktop\Reports\TestFolder"

End If

Thanks,
TAMATAM

Featured Post from this Blog

How to compare Current Snapshot Data with Previous Snapshot in Power BI

How to Dynamically compare two Snapshots Data in Power BI Scenario: Suppose, we have a sample Sales data, which is stored with Monthly Snaps...

Popular Posts from this Blog