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:
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.
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!
Bookmarks are quite helpful in a document. You may want to transfer the contents of a bookmark into a macro variable in ...
Discover MoreBookmarks can be a great tool in Word, allowing you to easily remember the location of desired blocks of text. If you ...
Discover MoreWord allows you to create a cross-reference to several different types of content in your documents. For instance, you ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
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.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2026 Sharon Parq Associates, Inc.
Comments