Bookmarking Headings as a Default

Written by Allen Wyatt (last updated January 3, 2026)

Ann regularly converts legal briefs prepared in Word to PDFs for electronic filing, and court rules require all headings to be bookmarked in the PDFs. Occasionally she forgets to set the options to bookmark the headings. Ann wonders if there is a way to set this option as a default within Word.

There is not a way to specify this setting as a default, but you can create a macro that will save the PDF file with the setting handled the way that Ann prefers. Here is a rather simple macro to accomplish the task:

Sub SavePDFBookmarks()
    Dim FDia As FileDialog
    Dim pdfPath As String
    Dim sPath As String
    Dim sName As String

    With ActiveDocument
        sPath = Options.DefaultFilePath(wdDocumentsPath)
        If Len(.Path) > 0 Then sPath = .Path
        sPath = sPath & Application.PathSeparator
        sName = Left(.Name, InStr(.Name, ".") - 1)
        sName = sName & ".pdf"

        Set FDia = Application.FileDialog(msoFileDialogSaveAs)
        FDia.InitialFileName = sPath & sName
        If FDia.Show = -1 Then
            pdfPath = FDia.SelectedItems(1)
            .ExportAsFixedFormat _
              OutputFileName:=pdfPath, _
              ExportFormat:=wdExportFormatPDF, _
              CreateBookmarks:=wdExportCreateHeadingBookmarks
        End If
    End With
End Sub

The macro determines the proper path for the PDF file (it defaults to the same path as used by the active document) and determines a new filename that has a PDF extension. It then displays the Save As dialog box so that the user can, if desired, choose a different location for the PDF file. When the user clicks OK in the dialog box, the document is saved as a PDF file with bookmarks formed from headings in the document.

There are a few cases where the macro could run into problems. For instance, if the active document doesn't have a filename extension or if the filename contains multiple periods. The macro, as written, works perfectly if there is only a single period between the base filename and the filename extension, but can produce wonky results if that is not the case.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (10056) applies to Microsoft Word 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Sending Printer Commands

If you need to send a command directly to your printer, then you need to use the PRINT field. It allows you to send ...

Discover More

WordTips: The Macros

Word includes a powerful macro programming language called Visual Basic for Applications. WordTips: The Macros can ...

Discover More

Counting Consecutive Negative Numbers

If you have a range of values that can be either positive or negative, you might wonder how to determine the largest ...

Discover More

Do More in Less Time! An easy-to-understand guide to the more advanced features available in the Microsoft 365 version of Word. Enhance the quality of your documents and boost productivity in any field with this in-depth resource. Complete your Word-related tasks more efficiently as you unlock lesser-known tools and learn to quickly access the features you need. Check out Microsoft 365 Word For Professionals For Dummies today!

More WordTips (ribbon)

An Automatic File Name

Do you have a set "standard" for how you name new documents? If so, you may be interested in implementing the technique ...

Discover More

Lost Data in Word

Use Word long enough and you eventually will lose some of your work. (And, it seems to be a rule that this will occur ...

Discover More

Setting a Document Naming Convention

Want your document file names to follow a specific naming convention? Word doesn't provide a direct way to set up your ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is seven more than 1?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.