Create non-existing folder on Save

S

Sean

If I use VBA to tell a document to be saved in a specific location, and that
specific location does not yet exist, how can I override the error and just
create that new folder/structure using code?

Thanks.
 
J

Jay Freedman

Sean said:
If I use VBA to tell a document to be saved in a specific location,
and that specific location does not yet exist, how can I override the
error and just create that new folder/structure using code?

Thanks.

You can use the FileSystemObject to check whether the folder exists, and if
it doesn't exist, to create it.

Once the folder is known to exist, there won't be any error on the save
(although there could be one on the create if the user doesn't have
permission for that action in the parent folder). Use an On Error statement
to trap any error that does occur.

See this thread for sample code:
http://groups.google.com/group/micr...author:freedman&rnum=1&hl=en#e065b3a9d318d3e5
 

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