Creating Folders
The MkDir function is used to create Windows folders from VBA. Some examples of MkDir are:
Create a folder called DicksStuff under the current directory
MkDir “DicksStuff”
MkDir “DicksStuff”
MkDir “DicksStuff”
Create a folder on the C drive regardless of the current drive or directory
MkDir “C:DicksStuff”
MkDir “C:DicksStuff”
Create a folder one directory back from the current directory
MkDir “..DicksStuff”
Create a folder at the root directory of the current drive
MkDir “.DicksStuff”
You can’t create more than one level at a time. If you want to create C:DicksStuffPrivate, you have to issue two MkDir functions
MkDir “C:DicksStuff”
MkDir “C:DicksStuffPrivate”
If you try to MkDir a directory that already exists, you get an error (which is just silly). Use an On Error statement to avoid an error if the directory may exist.
Certain comments are subject to moderation and may not appear immediately. You can use HTML tags in your comment. If you include a greater-than or less-than sign or anything else that could be interpreted as HTML, your comment won't look nice. You need to escape those characters. To post VBA code in your comment, use [VB] tags, like this: [VB]Code goes here[/VB].
Leave a comment