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: Selecting a Bookmark in a Macro.

Selecting a Bookmark in a Macro

by Allen Wyatt
(last updated December 14, 2015)

2

You can select the text or document location referenced by a bookmark very easily with a macro. For instance, let's say you had a bookmark named MyBkMark, and you wanted to select the text it represents. The following code fragment will do the trick:

ActiveDocument.Bookmarks("MyBkMark").Select

You should note that the above will only work if you know the name of the bookmark. If you don't know a particular bookmark's name, you can use an index offset instead, as follows:

ActiveDocument.Bookmarks(3).Select

When this code line is executed, the bookmark represented by index 3 is selected, regardless of the name. Another alternative, of course, is to retrieve the name of the defined bookmarks and then use them within your code.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (799) 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: Selecting a Bookmark in a Macro.

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

Removing Automatic Lines

Type a few dashes, underscores, or equal signs, and you could end up with a full-width line in your document. This is normal ...

Discover More

Excel Serious Sorting (Special Offer)

Excel Serious Sorting shows you how to put your data into the order that makes best sense. Increase your proficiency ...

Discover More

Two Printed Copies to Different Paper Trays

Many modern printers include multiple paper trays that can be used for different types or colors of paper. Word allows you to ...

Discover More

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!

More WordTips (menu)

Accessing Paragraphs in a Macro

Need to process a document, paragraph by paragraph, in a macro? It's easy to do once you understand that Word's object model ...

Discover More

Character Frequency Count

Word collects a wide range of statistics about your documents, but one of the things it doesn't collect is how many times ...

Discover More

Understanding Document Variables

When working with macros, you may want to create a variable that will remain constant from one instance of the macro to ...

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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 8Mpixels. 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 5 + 0?

2015-11-16 08:38:42

Alyssa

Hello,
I made a template with Checkboxes that hide/show certain tables with fill in content controls. IN my tmeplate the boxes work perfect and hide and show the bookmarked tables they refer to. But when I open a new document from the template, there seems to be nologic to what bookmarked tbale opens. For instance CheckMarkNew opens TableTools.
I even looked to make sure the book mark still took me to the correct table and it does.

What do you think the problem is?

here is an example of the code:


Private Sub CheckBoxNew_Click()

Bookmarks("NewTable").Range.Font.Hidden = CheckBoxNew.Value = False

End Sub


2014-12-12 05:01:54

Laurent

Hi Allen,

I would like to know if there is a limit in bookmarks numbers ? At the moment, there is a problem with one of my Word 2010 macro. Use to now, until 402 bookmarks, it was ok. But, beyond 402 bookmarks, there's a bug in execution.

Regards from France,

Laurent


This Site

Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.

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.