Identifying Duplicate Bookmarks

Written by Allen Wyatt (last updated August 1, 2026)

Nigel has a document in which bookmarks have been used extensively. He wonders if there is an easy way to identify bookmarks that either point to the same document location or that overlap with one another.

There is no built-in feature in Word to highlight duplicate or overlapping bookmarks. However, because Word stores each bookmark's starting and ending character positions and makes those positions available to VBA, you can identify duplicates and overlaps using a macro. The trick is to recognize where bookmarks can occur and how the start/end locations can relate to each other.

Here is a macro that will create a new document and provide a report about the bookmarks in the current document:

Sub CheckBookmarks()
    Dim bm1 As Bookmark
    Dim bm2 As Bookmark
    Dim docSource As Document
    Dim docTarget As Document
    Dim i As Long
    Dim j As Long
    Dim countDuplicates As Long
    Dim countContains As Long
    Dim countOverlaps As Long
    Dim sTemp As String

    Set docSource = ActiveDocument
    If docSource.Bookmarks.Count < 2 Then
        MsgBox "Fewer than 2 bookmarks; nothing to compare.", vbInformation
        Exit Sub
    End If

    Set docTarget = Documents.Add
    countDuplicates = 0
    countContains = 0
    countOverlaps = 0

    Selection.TypeText "=== BOOKMARK AUDIT REPORT ===" & vbCrLf
    Selection.TypeText "Total bookmarks: " & _
      docSource.Bookmarks.Count & vbCrLf & vbCrLf

    For i = 1 To docSource.Bookmarks.Count - 1
        Set bm1 = docSource.Bookmarks(i)

        For j = i + 1 To docSource.Bookmarks.Count
            Set bm2 = docSource.Bookmarks(j)
            sTemp = ""

            If bm1.Range.InStory(bm2.Range) Then
                If bm1.Start = bm2.Start And bm1.End = bm2.End Then
                    sTemp = "[EXACT MATCH] '" & bm1.Name & "' and '" & _
                      bm2.Name & "' have the same start/end positions"
                    countDuplicates = countDuplicates + 1
                ElseIf bm1.Start = bm1.End And bm1.Start >= bm2.Start _
                  And bm1.Start <= bm2.End Then
                    sTemp = "[CONTAINED] Zero-length bookmark '" & _
                      bm1.Name & "' is within '" & bm2.Name & "'"
                    countContains = countContains + 1
                ElseIf bm2.Start = bm2.End And bm2.Start >= bm1.Start _
                  And bm2.Start <= bm1.End Then
                    sTemp = "[CONTAINED] Zero-length bookmark '" & _
                      bm2.Name & "' is within '" & bm1.Name & "'"
                    countContains = countContains + 1
                ElseIf bm1.Start >= bm2.Start And bm1.End <= bm2.End Then
                    sTemp = "[CONTAINED] '" & bm1.Name & _
                      "' is completely within '" & bm2.Name & "'"
                    countContains = countContains + 1
                ElseIf bm2.Start >= bm1.Start And bm2.End <= bm1.End Then
                    sTemp = "[CONTAINED] '" & bm2.Name & _
                      "' is completely within '" & bm1.Name & "'"
                    countContains = countContains + 1
                ElseIf bm1.Start < bm2.End And bm1.End > bm2.Start Then
                    sTemp = "[PARTIAL OVERLAP] '" & bm1.Name & "' and '" & _
                      bm2.Name & "' partially overlap each other"
                    countOverlaps = countOverlaps + 1
                End If
            End If

            If Len(sTemp) > 0 Then Selection.TypeText sTemp & vbCrLf
        Next j
    Next i

    Selection.TypeText vbCrLf & "Audit Complete" & vbCrLf
    Selection.TypeText "    Duplicate pairs: " & countDuplicates & vbCrLf
    Selection.TypeText "    Containment pairs: " & countContains & vbCrLf
    Selection.TypeText "    Overlap pairs: " & countOverlaps & vbCrLf

    MsgBox "Bookmark audit finished.", vbInformation
End Sub

There are a few things to keep in mind with a macro such as this. First, the macro doesn't do any evaluation of the hidden bookmarks maintained by Word. This should not be an issue for Nigel's purposes, as he doesn't mention hidden bookmarks in his initial query.

Another thing to remember is that this macro doesn't list all bookmarks in its output. It only deals with bookmark pairs where there is some sort of overlap between the start/stop positions. These are the relationships highlighted in the output:

  • Start/end positions are the same for a bookmark pair.
  • A zero-length bookmark is contained within another bookmark.
  • A bookmark is contained within another bookmark entirely.
  • A portion of one bookmarks overlaps with another bookmark.

Note that the macro only looks at bookmark pairs within the same story. This is because it doesn't make sense to compare a bookmark in one story (such as a header) with a bookmark in another story (such as the main text).

Finally, the macro only reports on what it finds. It does not make any changes to the document, such as deleting or repositioning bookmarks. Any necessary changes should be done manually, based on the output of the macro.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (13990) applies to Microsoft Word 2007, 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

Vertical Lines in Word

Lines can help to organize the data on a page or make certain points clearer. Word provides several different ways you ...

Discover More

Separating Names into Individual Columns

If you have a list of names in a column, and you want to separate those names into individual cells, there are several ...

Discover More

Changing the Default Font

It makes sense that when Excel creates a blank workbook, it must figure out which font to use for that workbook. ...

Discover More

Discover the Power of Microsoft Office This beginner-friendly guide reveals the expert tips and strategies you need to skyrocket your productivity and use Office 365 like a pro. Mastering software like Word, Excel, and PowerPoint is essential to be more efficient and advance your career. Simple lessons guide you through every step, providing the knowledge you need to get started. Check out Microsoft Office 365 For Beginners today!

More WordTips (ribbon)

Setting a VBA Variable from a Bookmark

Bookmarks are quite helpful in a document. You may want to transfer the contents of a bookmark into a macro variable in ...

Discover More

Printing a Bookmark List with Contents

Bookmarks can be a great tool in Word, allowing you to easily remember the location of desired blocks of text. If you ...

Discover More

Finding Cross-References to Specific Bookmarks

Word allows you to create a cross-reference to several different types of content in your documents. For instance, you ...

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.