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

Hiding Macros

Need to hide some macros in your workbook? There are three ways you can do it, as covered in this discussion.

Discover More

Leaving Trace Precedents Turned On

The Trace Precedents auditing tool can be quite helpful in seeing which cells "feed into" a particular formula. The results ...

Discover More

Adding Circles around Letters or Numbers

Want to add some handy circles around text in your document? Believe it or not, Word provides three ways you can accomplish ...

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)

Screen Flip Flop with VBA

Word allows users to conveniently work with multiple documents at the same time. When writing macros, you may need to know ...

Discover More

Inserting a Break with a Macro

Inserting a break in your document is easy. You may think that inserting one using a macro is more complex, but it isn't. ...

Discover More

Determining How Many Styles are Available

Got a macro that processes or uses styles? You definitely need to know how many styles Word has available in the document. ...

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 6Mpixels. 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 6 - 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.