Creating Windows Folders

R

Rich K

I'm automating the creation of windows folders from a stored procedure in an
Access Module. I ask the user for a name for the folder after he's
identified the location.
What I'm looking for is code that varifies that the name is a valid windows
folder name before I try to create it. Is there something built into vba for
this purpose?

Thanks.
 
D

dymondjack

Check out the Dir() function

If you look at the help file, it will tell you how to use the arguments.
One of them can be used for dealing with directories. I don't remember the
syntax offhand, but if you should be able to pass the proposed name and the
vbDirectory constant to check for the existance of the folder.

hth

--
Jack Leach
www.tristatemachine.com

- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain
 
R

Rich K

Actually, the MkDir($Name) function is perfect for creating a folder with the
name $name.
What I'm looking for is a function that will varify if $Name is a valid
windows folder name before I pass it. I'm building the folders while
simultaneously building a tree view. I have to build the tree view first,
and then create the folder.

If I can validate the folder name prior to the tree view, I can simple abort
the process, but if I have to wait until I try to create the folder to find
out if it can be created, I would have to roll back several functions.

Thanks.
 
D

dymondjack

Ah...

I'm not sure about a vba function to validate a prospective folder name. I
thought you meant to check for the existence of that folder first.

I suppose an alternative would be to run the mkdir command, and before going
much further, check to see if that directory now exists (using the Dir
function). If it doesn't exist, obviously there was some error creating it,
and you can abort your treeview process. For example, have a 'dummy' folder
set up in your db location to perform this test before starting on the
treeview.

That would be the only way that I know off the top of my head, though it
does seem as thought there would be an API to handle something like this.
Probably there is, I just don't know of it.

--
Jack Leach
www.tristatemachine.com

- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain
 
R

Rich K

Thanks for the input.
I think I'll go ahead and change my code to create the folder first. I was
hoping for a quick solution but I think yours will end up being as elegant as
anything I can come up with.
 
R

Rich K

I think I just changed my mind and will use the first one.
I had thought of that originally but figured I'd miss some charactors to
evaluate.
 
D

dymondjack

Unfortunately I'm not sure how accurate that post is... only as good as the
guy posting it. Its seems well enough but don't know for sure. You could,
if you want, manually create a folder with a wrong char, and windows will
generally give you a blurb saying what characters can't be used in a
filename. You could double check those against the ones in the xtremevb post.

--
Jack Leach
www.tristatemachine.com

- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain
 

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