Link to home
Create AccountLog in
Avatar of Wortkoetter

asked on

Check for a specific folder

I am looking a vba script to run in ms excell to check if a specific directory exsists.  If the directory doesn't exsists the script should create it.  If the directoru exsists then the script should do nothing.
Avatar of MikeQc
Flag of Canada image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account

myFolder : full path of your folder for which you are looking...

Sub CheckFolder(Byval myFolder as String)

   Dim fso
   Set fso = CreateObject("Scripting.FileSystemObject")
   If fso.FolderExists(myFolder)=false Then
      fso.CreateFolder myFolder
   End If
End Sub
Wortkoetter, sorry if I confused you but the

Dim fso, msg
should only be
Dim fso

msg was another variable used elsewhere in my code... Sorry for the copy/paste.
Btw, the example was working anyway.

(rajvihari, what is the "plus value" of your post?)