Create folder on directory with command button? (1 Viewer)

vidus

Confused User
Local time
Today, 14:55
Joined
Jun 21, 2009
Messages
117
Hey all, we have a command button called [activate] which goes through a number of processes, asks for some values, sets some fields to true etc...

I am wonder if it is possible for me to add the creation of a folder to these processes. Lets say I want to create a folder using [Job] as the name, in directory c:\

Is this something that can be done? I already have a button to open a folder using the [Job] as the folder name, but I would like to automate its creation. :D
 

vidus

Confused User
Local time
Today, 14:55
Joined
Jun 21, 2009
Messages
117
Solved! For people searching, this will work:

MkDir ("C:\" & Job.Value)
 

SOS

Registered Lunatic
Local time
Today, 14:55
Joined
Aug 27, 2008
Messages
3,514
You'll want to check first to see if it already exists though:

Code:
If Dir("C:\" & Job.Value, vbDirectory) = "" Then
   MkDir("C:\" & Job.Value)
End If
 

vidus

Confused User
Local time
Today, 14:55
Joined
Jun 21, 2009
Messages
117
You'll want to check first to see if it already exists though:

Code:
If Dir("C:\" & Job.Value, vbDirectory) = "" Then
   MkDir("C:\" & Job.Value)
End If

In my case the value is from an input box, which is verified before the MkDir line plays out.
 

SOS

Registered Lunatic
Local time
Today, 14:55
Joined
Aug 27, 2008
Messages
3,514
In my case the value is from an input box, which is verified before the MkDir line plays out.
As long as the check is being done before creation that is good. I believe it would be more logical to do the check just before the creation (in case someone might have done it at some point before it is attempted here). For things like this I think it is really good to keep the check and the creation very close together. But whatever works for you. Glad you got it.
 

Users who are viewing this thread

Top Bottom