Code: Select all
Option Compare Database
Option Explicit
Private PDFFactory As New PXCComLib7.CPXCControlEx
Private WithEvents PDFPrinter As PXCComLib7.CPXCPrinter
Public Sub PDFXchangeDruck()
Dim strFullPath As String
Dim strPrinterOld As Printer
Dim prtLoop As Printer
Dim strPfad As String
Dim strName As String
Dim strBericht As String
DoCmd.Hourglass True
strPfad = GetParameterStr("ini_PDFDestinationpath")
strBericht = "Testbericht"
strName = CStr(Auftr) + "_" + strBericht + "_" + Format(Now, "yyyymmdd_hhmm") + ".pdf"
strFullPath = strPfad + "\" + strName
Set strPrinterOld = Application.Printer
For Each prtLoop In Application.Printers
If prtLoop.DeviceName = "PDF-XChange" Then
Set Application.Printer = prtLoop
Exit For
End If
Next
Set PDFPrinter = PDFFactory.Printer("", "PDF", "SN", "")
PDFPrinter.Option("Save.SaveType") = "pdfSaver" 'pdfSaver Save
PDFPrinter.Option("Save.ShowSaveDialog") = "No"
PDFPrinter.Option("Save.WhenExists") = 1 '"Overwrite"
PDFPrinter.Option("Save.RunApp") = "No"
PDFPrinter.Option("Save.Path") = strPfad
PDFPrinter.Option("Save.File") = strName
PDFPrinter.ApplyOptions 0
DoCmd.SelectObject acReport, Reports(0).Name
DoCmd.PrintOut acPrintAll, , , acHigh
Set Application.Printer = strPrinterOld
If m_bolPDFOpen Then
FollowHyperlink strFullPath
End If
DoCmd.Hourglass False
End Sub
Am I doing something wrong? If so, how can I do this correctly? I use PDF XChange 9 PRO