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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check if a folder already exists ...

Status
Not open for further replies.

Rodie

Programmer
Jun 27, 2004
132
FR
Hi all

I would like to create a new folder, but only if it does not already exist.
Here is my code which does not work ...

Code:
Dim New_folder_name As String 
New_folder_name = ThisWorkbook.Path & "\MyFolder" 
Dim fso As New FileSystemObject 
If Not fso.FolderExists(New_folder_name) Then 
  MkDir New_folder_name 
Else 
  MsgBox " The folder already exists. " 
End If
I found the line with FileSystemObject on the Internet but it does not work ...

Thanks in advance ...
Rody [2thumbsup]
 
it does not work
Any chance you may be more specific on the the issue ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Did you add a reference to the Microsoft Scripting Runtime Library?

-Gary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top