Is it possible to write code to create a folder. What I want to do is if this folder does not exist, create the folder and save the file. How can I do this?
Printable View
Is it possible to write code to create a folder. What I want to do is if this folder does not exist, create the folder and save the file. How can I do this?
Take a look at the FileSystemObject.
Try the MkDir procedure. :rolleyes:
How do I do that? I am a beginner. Also, keep in mind I am using VBA. Please help
Code:Private Sub Form_Load()
'check to see if a dir exists
Dim sDir As String
sDir = "C:\my documents\helpmeout"
If Dir(sDir, vbDirectory) <> "" Then
MsgBox "Exist"
Else
ChDir "C:\my documents"
MkDir (sDir)
'then do your save or whatever
End If
End Sub