Share via

I have a word macro that I want to save the active document as a PDF to a nominated address, It works by opening the pdf in a pdf reader but won't svae to the nominated address.

Anonymous
2025-06-03T06:56:58+00:00

The cide fr the Macro is :

4  Save as a PDF and Open

    Sub SaveAsPDFAndOpen()

    Dim Terms As String

    Dim number As String

    Dim office As String

    Dim filePath As String

    ' Get the content of the bookmarks

    Terms = ActiveDocument.Bookmarks("Terms").Range.Text

    number = ActiveDocument.Bookmarks("Number").Range.Text

    ' Construct the file path

    filePath = " G:\Shared drives\AuSIL Bookshop\Invoices-Receipts\Darwin Invoices" & "_" & number & "_" & Terms & ".pdf"

    ' Save the document as PDF

    ActiveDocument.ExportAsFixedFormat _

        OutputFileName:=filePath, _

        ExportFormat:=wdExportFormatPDF

    ' Open the PDF file

    Shell "C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe """ & filePath & """", vbNormalFocus

End Sub

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Paul Edstein 82,861 Reputation points Volunteer Moderator
    2025-06-03T08:25:03+00:00

    Try:

    ActiveDocument.SaveAs FileName:=filePath, FileFormat:=wdFormatPDF, AddToRecentFiles:=False

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments