automatically creating a folder

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
 
M

martin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top