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

Canceling a Command

Need to cancel a command you've already started? It is as easy as pressing a single keystroke.

Discover More

Sending Single Worksheets via E-mail

Got a single worksheet that you want to e-mail to someone, but don't want them to see the rest of the worksheets in the ...

Discover More

Stepping through Sentences

Need to select an entire sentence at once? You can do so by creating a short macro that does the task for you, or you can ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 365 applications with VBA programming. Written in clear terms and understandable language, the book includes systematic tutorials and contains both intermediate and advanced content for experienced VB developers. Designed to be comprehensive, the book addresses not just one Office application, but the entire Office suite. Check out Mastering VBA for Microsoft Office 365 today!

More WordTips (ribbon)

Preserving Bookmarks During Replace Operations

When you do a search and replace operation in Word, it is possible that you could inadvertently wipe out a bookmark or ...

Discover More

Automatically Referencing Info Entered in a Table

Tables are a great way to organize information in a document. At some point you may want a cell in a table to contain the ...

Discover More

Deleting a Bookmark

Create a bookmark and you may, at some future point, need to delete that bookmark. It's easy to do, as described in this tip.

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 7 + 1?

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.