Link to home
Start Free TrialLog in
Avatar of Bob Collison
Bob CollisonFlag for Canada

asked on

Access 2010 Export Report As PDF With Custom Filenemae

Hi Experts,
When I Preview a report in MS Access 2010 and want to save it as a PDF the File Name defaults to the Report Name.  e.g. Report 1

Is there a way to change the File Name to something Custom?  e.g. Report 1 - 2019-01-30.

Thanks,
Bob C.
Avatar of Daniel Pineault
Daniel Pineault

I'm assuming in VBA, change the caption of the report before printing/saving.
Avatar of Bob Collison

ASKER

Hi Daniel,

Yes using VBA in Access.

I'm not sure of the 'Caption' part but it would be the File Name in the Export Window.

Thanks,
Bob C.
Sorry, even easier

Dim sPDFPath As String
Dim sPDFName As String
sPDFPath = "C:\Temp\"
sPDFName = "Temp_xxxxxx.pdf"
DoCmd.OutputTo acOutputReport, "tbl_ClickTracking", acFormatPDF, sPDFPath & sPDFName

Open in new window

Hi Daniel,

This looks good but I'm not sure where to put the code.

All of my reports display as Preview Report using code like the following.  The user then has the option of selecting the Export as a PDF from the Ribbon.  It's at this point that I would invoke this code but I don't know how.

'Step 892-Display Report.
Dim stDocName_Rnnnnn As String
stDocName_Rnnnnn = "R-nn-nnn - Report Name."
DoCmd.OpenReport stDocName_Rnnnnn, acPreview

Thanks,
Bob C.
Hi Daniel / Experts,

Any more suggestions / answers to the above?

Thanks,
Bob C.
ASKER CERTIFIED SOLUTION
Avatar of Bob Collison
Bob Collison
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