Microsoft Access

Top  Previous  Next

The following example shows the basic code to open and print an Access report to Win2PDF.  This example uses SaveSetting to set the PDF file name and will suppress the Win2PDF File Save dialog.

 

Private Sub cmd_PrintToWin2PDF_Click()

 

'This code assumes that Win2PDF is set as the default printer.

On Error GoTo Err_cmd_PrintToWin2PDF_Click

 

  Dim stDocName As String

 

  'set the output file name

  SaveSetting "Dane Prairie Systems", "Win2PDF", "PDFFileName", "c:\AccessTest.pdf"

 

  stDocName = "Report to be converted"

  DoCmd.OpenReport stDocName, acNormal

 

Exit_cmd_PrintToWin2PDF_Click:

  Exit Sub

 

Err_cmd_PrintToWin2PDF_Click:

  MsgBox Err.Description

  Resume Exit_cmd_PrintToWin2PDF_Click

 

End Sub