Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if folder exists and if not create 1

Status
Not open for further replies.

clhare

Technical User
May 29, 2003
118
US
Is there an easy way to check and see if a specific folder already exists, and if it doesn't, create the folder?
 
I should probably add that I am working in Word.

I apologize for the double entry in the forum. I got an error the first time, but it apparently made it anyway!
 
Use the File System Object:

Set FSO = CreateObject("Scripting.FileSystemObject")

Then just test for the folder and/or create it:

If Not FSO.FolderExists(FolderPath) Then
Set CreatedFolder = FSO.CreateFolder(FolderPath)
End If
 
Thank you for the code! This works beautifully! Are the variables FSO and CreatedFolder both objects then?

Cheryl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top