save to reports to file using vba

griffins69

griffins69
Local time
Yesterday, 22:05
Joined
Apr 15, 2010
Messages
18
I would like to print and save reports to txt file using part of the report name and timestamp using VBA. We open many reports and need them saved and printed and it takes hours to do.

I would like to automate it


thanks
 
At least make an effort of trying to figure out how to do it on your own first. Then post back where you're getting stuck...

Telling us "I would like to automate it" isn't much of an effort... :)
 
The problem I'm having is saving the file as PDF. I can save the file manually as PDF because I set up a PDF printer and I can run
DoCmd.OpenReport "rpt_078", acViewNormal,
to save the report.

What I can't seem to do is get a a file name put in there thru VBA and save it.

DoCmd.OutputTo allows me to put in a directory, but a can't create PDF this was.
 
Haven't tried this... But, maybe you could use the 'copyobject' method to create a new report with the timestamp as part of it's name then export that. Delete the temp report (object) to clean up after yourself.
 
You can tell it to set the default printer to pdf with:

SetDefaultPrinter ("Adobe PDF")

Print the report and then set it back with:

SetDefaultPrinter (original)

Not sure this will get you where you need but maybe it'll help a little...
 
Ken

When I set it to the PDF to print(saving to PDF) it's asking me for a name for the file. This is not a problem when I'm doing manually, but when i want to give the file a name and save it thru VBA I don't know how to do it.

HGMonaro
I will give it a shot....Thanks
 
Sorry, I don't know of a work around. The copy thing may be your only option unless somebody else has an idea...
 
sounds like it's the PDF printer software that's asking for the name (one I use does that too). Might have to see if you can get that to accept the default name (created from the report name so you'd still need to create a report with the name you want) and just create the file without the prompt.
 
How do i created it without the prompt? I need thiis prompt for PDF file option
 
no idea... it might not be able to do it. Time to google something like 'print without prompt using CutePDF" (swap CutePDF for whatever you're using).
 
alternatively, upgrade to Acess 2010, just read a few things that indicate that can do it natively! That would fix it! :)
 
Hi,

I am new here, but here is what I used to output to pdf file. Using Access 2007 here.

Dim OutPDFName As String
DoCmd.OutputTo acOutputReport, "ReportNAme", acFormatPDF, "FileName", True
 
thanks to everyone who reponded.

I'm looking forward to going to Access2007, I'm currently in Access2003 and used
Stephen Leban's site and it worked perfectly.
 

Users who are viewing this thread

Back
Top Bottom