Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Preserving Bookmarks During Replace Operations.

Preserving Bookmarks During Replace Operations

by Allen Wyatt
(last updated September 8, 2012)

1

Bookmarks are a handy feature of Word, and they can be used for a variety of purposes. (Bookmarks have been discussed extensively in other WordTips.) When you define a bookmark, you essentially are providing a name by which either a location or a group of characters can later be referenced in a document. For instance, you could highlight a client's name, and then define a bookmark called Client that could be used elsewhere in the document to refer to the client's name.

When you do a search and replace operation, it is possible to inadvertently erase a bookmark. For instance, consider the following text:

This agreement between [John Doe] and [Mary Smith]
is entered into freely and without compulsion.

The brackets in this text indicate the beginning point and ending point of two bookmarks. (The brackets would not appear in the actual text; they are only provided here to help clarify the example.) If you search for either "John Doe" or "Mary Smith" and replace the names with new names, the bookmarks disappear. This can be a problem for other places in your document where you may reference the bookmarks. All of a sudden, there is nothing left to reference.

Why are the bookmarks deleted? Quite simply, it is because you have deleted the bookmark. Everything that was in the bookmark is gone, so Word no longer needs the bookmark and it is tossed aside. The solution to this problem is to be very careful in how you construct your bookmarks, or be careful in how you do your search and replace. For instance, you could define your bookmarks a bit differently:

This agreement between[ John Doe ]and[ Mary Smith ]
is entered into freely and without compulsion.

Note that in this example, the spaces surrounding the names are included in the bookmarks. Now, when you search and replace for the entire names, the text that makes up the bookmark is never deleted (the spaces would remain), so Word doesn't toss out the bookmarks.

The other option involves changing how you do your search and replace. Since the idea is to make sure that at least some of the text from the original bookmark remains in place after a search and replace operation, you can do two search and replace operations instead of one. For instance, if you want to replace John Doe with Margaret Brown, in your first search and replace you would replace John with Margaret and in your second search and replace you would replace Doe with Brown. The result is that you never fully replace the original text of the bookmark, and it should remain in place when you are done.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (856) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Preserving Bookmarks During Replace Operations.

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

Finding Wayward Links

Combining workbooks that have cross-links to each other can offer some special challenges. This tip examines how you can get ...

Discover More

Jumping to a Relative Footnote

Footnotes can be a great addition to any document that needs detailed referencing of citations. You can navigate from one ...

Discover More

Advanced Filtering

Many people know how to use AutoFilter, but there are times when you need some more filtering muscle. Here's how you can use ...

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 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!

MORE WORDTIPS (MENU)

Find and Replace in a Column or Row

Need to search for information in a table? Word allows you to easily limit your search to an entire column or row, as ...

Discover More

Keeping a Replace Operation Displayed

The Find and Replace tool is designed to help you find and replace information as quickly as possible. However, you may not ...

Discover More

Replacing Text with a Graphic

The Find and Replace feature in Word provides you with some powerful tools you can use to process a document. One such tool ...

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 for this tip:

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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. 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 8 - 1?

2013-01-28 08:19:22

lucio loiero

I've found just three handy methods to put bookmarks in the document - insert text inside the document and preserve them from cancellation.
Let'exam them:
1. Selection.GoTo What:=wdGoToBookmark, Name:="Firm"
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.InsertAfter Text)
Selection.Font.Name = "Tahoma"
Selection.Font.Bold = True
ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="Firm"
2.Public Sub InsertTextSaveBookmark()
Dim oRng As Range
Dim a As String
a = InputBox("Insert text")
Set oRng = ActiveDocument.Bookmarks("Firm").Range
oRng.Text = a
Selection.Bookmarks.Add Name:="Firm", Range:=oRng
End Sub
3.Public Sub InsertText()
Dim a As String
a = InputBox("Insert text")
ActiveDocument.Bookmarks("Firm").Range.Select
Selection.Delete
Selection.InsertAfter a
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeText Text:=" "
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="Firm"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
End Sub


Newest Tips
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.

Links and Sharing
Share