Link to home
Start Free TrialLog in
Avatar of James
JamesFlag for Canada

asked on

Can MKDIR in Access VBA automatically create intermediate folders?

I have code which creates a folder for a new invoice but the folders are in sub-folders by year. For instance, invoice 12345 would go into folder:

c:\invoices\2015\12345

Right now, the folder c:\invoices\2015 exists but not c:\invoices\2016

Is there a way to have MKDIR create any missing intermediate folders so that in 2016, c:\invoices\2016 will automatically be created when I try to create c:\invoices\2016\[invoice#] (similar to how the DOS command works if Command Extensions are enabled)? Or do I need to create the intermediate folders explicitly?
SOLUTION
Avatar of Nick67
Nick67
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It is very much the preferred way of working with files and folders.
In many environments you cannot use the Scripting Runtime, which is what drives the FileSystemObject classes. In some cases it's just a matter of adding exceptions to the virus engine, but I've run into situations where the IT department would not do that, and I've had to develop other methods (like the ones rey describes).
It's one thing to block .vbs files and wscript.exe and cscript.exe
But to blow up only some of the stuff called from a trusted VBA document?!?
But then, there's no accounting for the insanity of Symantec and McAfee.
They had loveletter and Melissa on the brain for quite a while.

So, if it is permitted, the filesystemobject is your friend.
If it is not permitted then you'll have to do the exact same thing with a different friend.

:)
Nick67
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial