Inserting the Line Number of a Bookmark

Written by Allen Wyatt (last updated April 19, 2025)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365


Hasan has a document that includes a bookmark. He wonders if there is a field he can use to indicate the line number on which the bookmark occurs.

The short answer is no, there is not a way to do this in Word. You can obviously turn on line numbering, jump to the bookmark, and note the line number on which it occurs. Since Hasan wants a field to indicate this line number, though, it seems like he ways a way to reference that line number elsewhere.

A field would be helpful to do this, but since none exists, you need to rely on a workaround using a macro. Here's a simple macro that could do the trick:

Sub TypeBookmarkLineNumber()
    Dim bm As Bookmark
    Dim bmRange As Range
    Dim lineNumber As Long

    Set bm = ActiveDocument.Bookmarks("MBN")
    Set bmRange = bm.Range
    lineNumber = bmRange.Information(wdFirstCharacterLineNumber)

    Selection.TypeText lineNumber & " "
End Sub

This macro assumes a couple of things. First, it assumes that you want the line number for a bookmark named "MBN." Second, it assumes that you want the line number entered in the document at the location of the insertion point.

A macro such as this is not as automatic as a field; it must be run every time you want the line number. (Obviously, this may mean deleting the line number generated by the macro the last time you ran it.) Plus, if the MBN bookmark stretches over more than a single line, it is only the line number of the first character in the bookmark that is entered in the document.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (9452) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365.

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

Replacing Text in a Macro

When using a macro to process text in a document, it is not unusual to replace one portion of a text string with another ...

Discover More

Adding Automatic Time Stamps

Your computer knows the current date and time, and Word provides ways you can get that date and time into your document. ...

Discover More

Summing Only Cells Containing Formulas

If you want to figure out the sum of all cells that contain formulas, there are a couple of ways you can go about it. ...

Discover More

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

More WordTips (ribbon)

Protecting Bookmarks

Bookmarks are a great boon in developing and working with documents--"until someone deletes them. When it comes to ...

Discover More

Random OLE Bookmarks

Word has an irritating habit of placing unwanted bookmarks in a document that you've been editing for a while. These ...

Discover More

Bookmark Error when Printing

Bookmarks are commonly used in Word documents as a way to cross-reference information. If the bookmark referenced by the ...

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}] (all 7 characters, in the sequence shown) 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 six more than 9?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

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

Videos
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.