Public Function RunReportAsPDF(rptName As String, sPDFPath As String, sPDFName As String) '--------------------------------- 'rptName = Microsoft Access report name ' you 'want to create pdf from 'sPDFPath = the directory path where you ' want 'to create the pdf file (ex. - "c:\data\ ' ") 'sPDFName = the name of the pdf file you ' are 'wanting to create (ex. - "file001.pdf") ' '--------------------------------- Dim sMyDefPrinter As String On Error GoTo Err_RunReport 'Save current default printer sMyDefPrinter = bGetRegValue(HKEY_CURRENT_USER, "Software\Microsoft\WIndows NT\CurrentVersion\Windows", "Device") ' Set default printer to PDF Writer bSetRegValue HKEY_CURRENT_USER, "Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device", "Acrobat PDFWriter" 'Setting value for PDFFileName in the re ' gistry stops file dialog box from appear ' ing bSetRegValue HKEY_CURRENT_USER, "Software\Adobe\Acrobat PDFWriter", "PDFFileName", sPDFPath + sPDFName 'Run the report DoCmd.OpenReport rptName, acViewNormal Exit_RunReport: ' Restore default printer bSetRegValue HKEY_CURRENT_USER, "Software\Microsoft\WIndows NT\CurrentVersion\Windows", "Device", sMyDefPrinter Exit Function Err_RunReport: MsgBox Err.Description Resume Exit_RunReport End Function
Gain unlimited access to on-demand training courses with an Experts Exchange subscription.Get Access
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE
Connect with Certified Experts to gain insight and support on specific technology challenges including: