How do I check to see if a directory exist before saving workbook
How do I check to see if a directory exist before saving workbook
Try this,
Edit: I forgot to mention, you only need the full path of the directory you want to check.
![]()
Sub FilePath() Dim fPath On Error GoTo Ext fPath = "C:\YourPathHere" If Not Dir(fPath, vbDirectory) = vbNullString Then MsgBox "Folder exists" Else MsgBox "Folder does not exist" End If Ext: On Error GoTo 0 End Sub
Last edited by JapanDave; 04-23-2013 at 09:07 PM.
Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
I am the real 'Napster'
The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...
If you receive help please give thanks. Click the * in the bottom left hand corner.
snb's VBA Help Files
Thank You for the help with this, it works great.
Check out this example.
Click the button, a userform will pop up and a combobox will populate with the folders in the C drive and the textbox will show what is in Range("L10")
Select a folder and click "Make New Folder" A folder will be made with the name that is in the textbox.
Click the button again, select the same folder in the combobox and click "Make New Folder"
You will get a message box telling you that the folder already exists.
It would be a good idea to first make a test folder in the C drive for experimental purposes.
Then you can select the test folder in the combobox
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks