Results 1 to 2 of 2

Thread: Need VBA to interact with PDFMaker addin
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Jul 2007
    Location
    England
    Posts
    443
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Need VBA to interact with PDFMaker addin

    Hi all,

    I have an Excel file with internal links that needs to be saved as PDF. I have found a way to manually do this using the PDFMaker add-in, but am now trying to automate this but am really struggling. I've tried to Google some results but have had no luck there either.

    Does anyone have any code that can call the PDFMaker, select some sheets and create the pdf from there?

    Thanks in advance.

  2. #2
    Board Regular
    Join Date
    Jul 2007
    Location
    England
    Posts
    443
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Need VBA to interact with PDFMaker addin

    I have managed to get the following code to open up the PDFMaker, but for some reason when I click on the Convert to PDF button it prints it to PDF instead, losing the links anyway:

    Code:
    Sub ExportToPDF()
    Dim pdfname, i, a
    Dim pmkr As AdobePDFMakerForOffice.PDFMaker
    Dim stng As AdobePDFMakerForOffice.ISettings
    If Not ActiveWorkbook.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 = ActiveWorkbook.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
    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

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •