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

Problem Printing Quotation Marks

If you go to print a document and find out that your quotation marks aren't printing properly, there could be a number of ...

Discover More

Printing a Draft of a Worksheet

Want to print out the fastest possible copy of your worksheet? You do so by printing a draft, discussed in this tip.

Discover More

Excluding a Specific Add-In at Startup

Got an add-in that you don't want loaded each time that Excel starts up? Here's a few ways that you can exclude it.

Discover More

Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth 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

Determining the Hour of the Day

Need to figure out the hour represented by a particular time value? It's easy to do in a macro; just use the Hour function, ...

Discover More

Determining Word Frequency

How to construct a word frequency list.

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 two more than 9?

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.

Links and Sharing