automatically creating a folder

  • Thread starter Thread starter Chad
  • Start date Start date
C

Chad

Is there a way to have Access automatically create a
folder in a specific location using VBA?

For example:

When cmdCreate is clicked a new folder is saved to the
path of C:\ as "New Folder"

Any help would be greatly appreciated.

Chad
 
This is what I did ...
Public Function createfolder(name As String, Optional
drive As String = "c") as boolean
Dim fs As Object, child, main
On Error GoTo errtext
Set fs = CreateObject("Scripting.FileSystemObject")
Set main = fs.GetFolder(drive & ":\")
createfolder = True
If Not fs.FolderExists(drive & ":\" & name) Then
Set child = main.SubFolders
child.add (name)
End If
Exit Function
errtext:
createfolder = False
End Function
 
Back
Top