archive a report (as .pdf) to a file directory

Currently, my users click on a button to create a report and then save it as a pdf to a directory.  How would i automate this process?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Russell FoxDatabase DeveloperCommented:
You can create a macro and give them a button to push when it's time to generate the file. Here are some instructions with images (start around step 8).
vbnetcoderAuthor Commented:
I would prefer VBA code if possible
Russell FoxDatabase DeveloperCommented:
Me, too:
DoCmd.OutputTo acOutputReport,"rptYourReport",acFormatPDF,"C:\Access\rptFoo.pdf"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

vbnetcoderAuthor Commented:
My client is telling me now that they want it in excel format. I am having issues when i do this

DoCmd.OutputTo acOutputReport,"rptYourReport",acFormatXLSX, "C:\Access\rptFoo.xlsx"

Run-time error 2282 The format you are attempting to output the current object is not available
Russell FoxDatabase DeveloperCommented:
Are you using Office 2007? There's a bug where you have to have Service Pack 2 installed in order to export to Excel:
vbnetcoderAuthor Commented:
Russell FoxDatabase DeveloperCommented:
It looks like you either have to use acFormatXLS or export the query, rather than the report, using DoCmd.TransferSpreadSheet().
vbnetcoderAuthor Commented:
so then the resulting spreadsheet needs to be .xls too?
Russell FoxDatabase DeveloperCommented:
Yeah, it looks that way. And since xslx is a completely different xml format, you can't just change the file type. Here's a powershell script that will do a conversion, though, if you can work it into your process. For example, you could send the file to a hidden folder and have a process that runs every few minutes to convert & move any xls file to a folder visible to your users.
vbnetcoderAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.