DoCmd.OutputTo Create folder if it doesn't already exist

flemmo

Registered User.
Local time
Today, 19:44
Joined
Apr 26, 2006
Messages
69
Hi,

I have a button that exports a report to RFT (then opens it) as follows:

DoCmd.OutputTo acReport, "QuotationRevisions", acFormatRTF, "C:\Reports\" & Year(Now()) & "\Report.rtf", -1

So if the button were to be clicked today (29/12/2008) the report would be saved to:
C:\Reports\2008\Report.rtf

However, if the folder "2008" isn't already created, the file wont save. I want it to automatically create a "2008" folder if it doesn't already exist. Is this possible?

Thanks
 
You can test for its existence with the Dir() function, and create it if it doesn't exist.
 
Search for "File system object" or "Filesystemobject" if you need to find out how to create the folder.
 

Users who are viewing this thread

Back
Top Bottom