Saturday, 31 October 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

No comments:

Post a Comment

Follow Me by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts