Problem with printing PDF from MSAccess 2013 VBA

PDF-XChange Drivers API (only) V4/V5
This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-XChange Printer Drivers SDK (only) - VERSION 4 & 5 - Please use the PDF-Tools SDK Forum for Library DLL assistance.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
tschroeer
User
Posts: 2
Joined: Mon Oct 11, 2021 6:26 am
Contact:

Problem with printing PDF from MSAccess 2013 VBA

Post by tschroeer »

I would like to automatically generate PDF documents from MIcrosoft Access 2013 Runtime. For this purpose I have created the following class:

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
Unfortunately, the options are not set and the PDF printer displays the "Save as" dialogue.

Am I doing something wrong? If so, how can I do this correctly? I use PDF XChange 9 PRO
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Problem with printing PDF from MSAccess 2013 VBA

Post by Ivan - Tracker Software »

Please use

Code: Select all

PDFPrinter.Option("Save.SaveType") = "Save"
instead of "pdfSaver"
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
tschroeer
User
Posts: 2
Joined: Mon Oct 11, 2021 6:26 am
Contact:

Re: Problem with printing PDF from MSAccess 2013 VBA

Post by tschroeer »

Ivan - Tracker Software wrote: Mon Nov 01, 2021 6:09 pm Please use

Code: Select all

PDFPrinter.Option("Save.SaveType") = "Save"
instead of "pdfSaver"
I had tried the "Save" option first. Because it did not work, I then switched to "pdfSaver", also without success.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17765
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Problem with printing PDF from MSAccess 2013 VBA

Post by Tracker Supp-Stefan »

Hello tschroeer,

The "Save" is also the default value:
https://help.pdf-xchange.com/pdfxd ... /save.html
So if you just skip setting this particular property does it then work for you?

Kind regards,
Stefan
Post Reply