Bookmarking Headings as a Default

Written by Allen Wyatt (last updated January 2, 2026)
This tip applies to Word 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365


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

Determining the Number of Bookmarks Defined in a Document

If you develop a macro that needs to work with bookmarks defined in a document, it is inevitable that you will need a way ...

Discover More

Pulling Cell Names into VBA

Excel allows you to define names that can refer to either ranges of cells or to constant information, such as formulas. ...

Discover More

Finding and Changing Word's Internal Commands

If you know how to create macros, you can easily create entire replacements for Word's internal commands. Here's all you ...

Discover More

The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2019. Spend more time working and less time trying to figure it all out! Check out Word 2019 For Dummies today!

More WordTips (ribbon)

Embedding TrueType Fonts

If you need to make sure that the fonts in your document can be used by another person or on a different system, you'll ...

Discover More

Finding Out the Folder for an Open Document

If you work with a lot of documents at the same time, it can be difficult to remember the folder in which any given ...

Discover More

Printing Documents in a Folder

If you want to print a group of documents at the same time, there are a couple of ways you can accomplish the task. Here ...

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 6 - 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.