View Single Post
 
Old 01-06-2021, 07:18 AM
eduzs eduzs is offline Windows 10 Office 2019
Expert
 
Join Date: May 2017
Posts: 262
eduzs is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
You F/R expression cannot of itself remove a bookmark unless the [ and ] characters span the whole bookmarked range. Although bookmark boundaries look like the typed [ and ] characters, they cannot be accessed using those characters in a F/R expression.
Hi macropod!

To show where's each bookmark/name in a document, I use this code:

Code:
Sub HighlightBookmarks()

Dim objBookmark As Bookmark, objDoc As Document

Application.ScreenUpdating = False
Set objDoc = ActiveDocument
With objDoc
    For Each objBookmark In .Bookmarks
        With objBookmark.Range
            .Text = "[ " & objBookmark.Name & " ]"
            .HighlightColorIndex = wdBrightGreen
        End With
    Next objBookmark
End With
Application.ScreenUpdating = True

End Sub
After that, I want to "undo" this action, so I use the above code (first), but this result in first bookmark at top of the document to be also deleted.

It is simple to reproduce the problem, insert a bookmark at the beginning of a document, type some text, insert another bookmark, run the macros, go to the list of bookmarks and see that the first bookmark is gone.

Thanks
__________________
Backup your original file before doing any modification.
Reply With Quote