Skip to main content
Participant
January 21, 2009
Question

How do I invoke Word PDFMaker from a macro?

  • January 21, 2009
  • 3 replies
  • 24437 views
Hi,

I need to automate creating PDF's from Word with hyperlink fields converted precisely. The Adobe toolbar "Convert to Adobe PDF" button does exactly what I need. How do I invoke this type of conversion programmaticially, e.g. from a Word macro? Can anyone point me to a SDK document that discusses this?

(BTW, printing the document to the "Adobe PDF" printer will not work. I need the exact functionality of the toolbar button).
    This topic has been closed for replies.

    3 replies

    Legend
    April 19, 2017

    All supported interfaces are described in the Acrobat SDK. Including Distiller. But Distiller has only one job: converting PostScript to PDF. It doesn't read Word documents. It would read PostScript generated by printing to file, but when you use PDFMaker it does not use printing, or PostScript, or Distiller.

    Participating Frequently
    January 22, 2009
    It might not be a wise thing to explore.
    http://support.adobe.com/devsup/devsup.nsf/docs/52841.htm
    July 13, 2009

    Sorry to kvetch, but do I understand correctly that Adobe removed this feature from Acrobat by declaring it unsupported.  For years I've been able to generate documents programmatically and store them as PDFs, with hyperlinks intact, with "Application.Run MacroName:='AdobePDFMaker.AutoExec.ConvertToPDF'."  Now this capability just disappears?  I would never have upgraded from Acrobat 6 had I known this.

    Bernd Alheit
    Community Expert
    Community Expert
    July 13, 2009

    These feature wasn't supported.

    Participant
    January 21, 2009
    I have found enough information to script the conversion, but not the actual documentation. I'd still appreciate any pointers anyone could give me to the documentation for the AdobePDFMakerForOffice.PDFMaker object.

    It would be pretty peculiar for this not to be documented since as far as I can tell, this is the only way to create PDF files from Word documents with functional intra- and inter-document hyperlinks. If there is a better, documented way please let me know by responding to this note!

    In any case, since I haven't seen this explained anywhere it might be useful to post some notes here. To script a conversion that doesn't require user intervention, get a reference to the PDFMaker add-in object from Word. From that, use the GetCurrentConversionSettings (or GetDefaultConversionSettings) method to get an ISetting object. Set property OutputPDFFilename to the desired PDF filename, and property PromptForPDFFilename to False. After making any other desired setting changes, use the PDFmaker object's CreatePDFEx property to perform the conversion.

    Here is a sample routine in Word VBA. Before you can run it, you must open the Word macro editor and using Tools > References, add a reference to your copy of AcrobatPDFMakerForOffice.tlb, in e.g. \Program Files\Adobe\Acrobat 8.0\PDFMaker\Office.

    >
    ' ----------------------------------------------------
    ' ConvertToPDFWithLinks - convert the current document
    ' to a PDF file, in the same folder as the document
    ' ----------------------------------------------------

    Sub ConvertToPDFWithLinks()
    Dim pdfname, i, a
    Dim pmkr As AdobePDFMakerForOffice.PDFMaker
    Dim stng As AdobePDFMakerForOffice.ISettings

    If Not ActiveDocument.Saved Then
    MsgBox "You must save the document before converting it to PDF", vbOKOnly, ""
    Exit Sub
    End If

    Set pmkr = Nothing ' locate PDFMaker object
    For Each a In Application.COMAddIns
    If InStr(UCase(a.Description), "PDFMAKER") > 0 Then
    Set pmkr = a.Object
    Exit For
    End If
    Next
    If pmkr Is Nothing Then
    MsgBox "Cannot Find PDFMaker add-in", vbOKOnly, ""
    Exit Sub
    End If

    pdfname = ActiveDocument.FullName ' construct output name
    i = InStrRev(pdfname, ".")
    pdfname = IIf(i = 0, pdfname, Left(pdfname, i - 1)) & ".pdf"

    ' delete PDF file if it exists
    If Dir(pdfname) <> "" Then Kill pdfname

    pmkr.GetCurrentConversionSettings stng
    stng.AddBookmarks = True ' make desired settings
    stng.AddLinks = True
    stng.AddTags = True
    stng.ConvertAllPages = True
    stng.CreateFootnoteLinks = True
    stng.CreateXrefLinks = True
    stng.OutputPDFFileName = pdfname
    stng.PromptForPDFFilename = False
    stng.ShouldShowProgressDialog = True
    stng.ViewPDFFile = False

    pmkr.CreatePDFEx stng, 0 ' perform conversion

    If Dir(pdfname) = "" then ' see if conversion failed
    MsgBox "Could not create " & pdfname, vbOKOnly, "Conversion failed"
    End If
    End Sub

    ' ----------------------------------------------------

    The steps of deleting the pdf file if it exists before converting and checking for the file after conversion are necessary. If the output file cannot be created (permissions, read-only, open etc) CreatePDFEx does not throw an error. It's better to find out.

    Note that Intellisense and the object browser can show you all of the available properties and methods of pmkr and stng. Here's the list, though I can't guarantee its accuracy -- I might have mistyped:

    PDFMaker methods:
    CreatePDF (retval as Long)
    CreatePDFEx (settings as AdobePDFMakerForOffice.ISettings, retval as Long)
    GetCurrentConversionSettings (byref settings as AdobePDFMakerForOffice.ISettings)
    GetDefaultConversionSettings (byref settings as AdobePDFMakerForOffice.ISettings)

    ISettings properties: (all Boolean except as noted)
    AddBookmarks
    AddLinks
    AddTags
    AdvancedTagging
    AllowBleeds
    AlwaysFlattenLayers
    AttachSourceFile
    ConversionRoute
    ConvertAllPages
    ConvertHiddenSlides
    ConvertMultimedia
    ConvertSpeakerNotes
    CreateDocInfo
    CreateFootnoteLinks
    CreateLayers
    CreateMetadata
    CreateTextNodes
    CreateThreads
    CreateXrefLinks
    FitToOnePage
    InvokedFromFeat
    IsAutomation
    IsConversionSilent
    JobOptions as String
    LayoutBasedOnPrinterSettings
    OpenLayerPane
    OutputPDFFileName as String
    PDFACompliance
    PreserveSpotColor
    PreserveTransparency
    PrintActiveSheetOnly
    PrintBleedMarks
    PrintCropMarks
    PromptForPDFFilename
    PromptForSheetSelection
    Reserved as Long
    SaveAnimations
    SaveSlideShowTransitions
    SecuritySettings as Object
    SendForReview
    SendViaEmail
    ShouldShowProgressDialog
    ViewPDFFile

    ISettings methods:
    GetConversionRange (byref Range)
    SetConversionRange (Range)
    Participant
    November 4, 2013

    I came across the above macro only recently (Nov 2013).  I can confirm that it works with Acrobat XI. I now have a nice macro that recursively scans a set of subdirectories and converts all word documents meeting my specific naming criteria to pdf.  Definitely a happy bunny so thanks to Brian.