Quote:
Originally Posted by macropod
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