A long or complex document can be difficult to navigate. Susan Harkins explains how Word's bookmarks can help.
Bookmarks identify text so you can quickly navigate to a specific spot instead of scrolling through several paragraphs or pages. While they're convenient to use sporadically, steady use can become tedious because there are so many keystrokes to using one.
Ultimately, bookmarks are much more than a navigation tool, because you can use them as links or references. In this article, we'll review their use for navigating a document. You can create bookmarks in most any Word document, or you can download the demonstration .docm if you'd like to follow along with an example file.
Before you begin
Don't try to insert bookmarks as you enter text and other objects. Most documents change quite a bit from their inception to completion. For that reason, you should wait until the document is complete, more or less, before inserting navigational bookmarks. Otherwise, you might find yourself moving, duplicating, or even deleting bookmarks unintentionally as you modify the document's text.
If you find you must move bookmarked text, keep the following behaviors in mind:
- If you copy all or part of a bookmarked text (or object) within the same document, the bookmark remains with the original text. The copied text isn't bookmarked.
- If you copy bookmarked text or an object in its entirety to another document, both documents will be bookmarked.
- If you move bookmarked text within the same document, the bookmark moves with the text.
- If you delete part of bookmarked text, Word won't delete the bookmark.
If you forget where your bookmarks are, you can display a visual clue as follows:
- Click the File tab (or Office button).
- Choose Options (or click Word Options).
- In the left pane, choose Advanced.
- In the Show document content section, check Show bookmarks (Figure A).
- Click OK.
Word will enclose bookmarked text in a set of brackets. You probably won't want to display these brackets in the final document, but turning on the display while completing the document is helpful.
Deciding where to insert the bookmarks shouldn't be difficult if the document is mostly done. Consider how you and your users will actually use the document. The process for inserting a bookmark is simple:
- Click where you want to add the bookmark. If you select text, select the smallest string that makes sense. It's okay to select a word or heading, but it's probably not a great idea to bookmark an entire paragraph.
- Click the Insert tab.
- Click Bookmark in the Links group.
- In the resulting dialog, give the bookmark a name. Use only letters and numbers with no spaces (Figure B).
- Click Add.
Figure C shows the bookmark. If you didn't enable the view for your document earlier, you won't see the brackets.
If you check the right option, Word will display bookmarks.
Using a bookmark
After inserting bookmarks, you can then use them to quickly move to other areas of the document. To use the bookmark in this way, do the following:
- Click the Insert tab and choose Bookmark from the Links group.
- In the resulting dialog, select the bookmark you want to move to (Figure D).
- Click Go To.
- Click Close.
Inserting bookmarks takes a few clicks, but it's easy. Once they're in place, you're done. On the other hand, moving to a bookmark might be a task you perform often. Even though doing so requires only a few clicks, it'll become tedious.
One possible alternative to tedious bookmark clicking is to use a hyperlink instead. You're probably familiar with hyperlinks, but you might not realize that Word will let you create them to navigate long documents. Users won't have to travel through the interface to use them — they'll just click the link.
The downside is the placement. Instead of choosing a bookmark from a list of bookmarks, you'll have only the hyperlink to click — users must be in that spot to utilize it. Still, in most documents, it's a useful navigational tool.
You can use existing text (which is the best option, when available) or enter text specifically to create a hyperlink. To create a hyperlink, find text that references the area you want the hyperlink to link to, or add text and select it. For this example, I added a heading for Buttons and selected it. Next, add the hyperlink as follows:
- Click the Insert tab.
- In the Links group, choose Hyperlink.
- In the resulting dialog, click the Place In This Document shortcut on the left.
- If you're using Word's built-in heading styles, you can link to one of those. In this case, link to the bookmark we created earlier, ButtonReference (Figure E).
- Click OK.
When you click the hyperlinked text (at the beginning of the document), Word selects the bookmarked text new buttons. It's a helpful addition, but if you're nowhere near the hyperlink when you decide to review the new buttons paragraph, the hyperlink doesn't help.
If your document contains several bookmarks, referring to them will become tedious. Offering a macro that displays a list of bookmarks that the user can then select is more efficient. Listing A includes several sub and function procedures that your users can run as a macro. It will display a UserForm that lists all of the document's bookmarks. The user simply selects a bookmark from the list to select that bookmark. I recommend that you add the macro to the Quick Access Toolbar (QAT) for even quicker access. That's where Listing B comes in. While in the VBA, insert a module and add this short procedure.
Don't attempt to copy and paste the code from this article into the UserForm's module because the VBE will object to web characters. Instead, download the demonstration .docm file or frmSelectBookmark.frm. If you want to import the UserForm yourself, you can by using the instructions that follow:
- Press [Alt]+[F11] to open the VBE.
- Select UserForm from the Insert menu. Name it frmSelectBookmark.
- Using Figure F as a guide, add the following controls:
- Double-click the UserForm to open its module and enter the code in Listing A. (If you copy the code from the web page into a Word document and then copy that code into the module, it might work, but I can't guarantee it.)
- Insert a module by selecting Module from the Insert menu.
- Enter the code in Listing B.
- Return to the document and save it as a macro-enabled document (if necessary).
Option Explicit Private m_gotoInProgress As Boolean ' Load bookmarks on bookmarks selection form activation. Private Sub UserForm_Activate() Dim bmk As Bookmark lstBookmarks.Clear For Each bmk In ActiveDocument.Bookmarks lstBookmarks.AddItem (bmk.Name) Next bmk txtBookmarkName.SetFocus End Sub ' Select bookmark using quick selection textbox. Private Sub txtBookmarkName_Change() If (Not isNullOrEmpty(txtBookmarkName.Text)) Then Dim bmkName As Variant Dim listIndex As Integer listIndex = -1 For Each bmkName In lstBookmarks.List listIndex = listIndex + 1 If (Len(bmkName) >= Len(txtBookmarkName.Text)) Then If (UCase(Left(bmkName, Len(txtBookmarkName.Text))) = UCase(txtBookmarkName.Text)) Then lstBookmarks.Selected(listIndex) = True Exit For End If End If Next bmkName End If End Sub ' Check if a string is null or empty. Private Function isNullOrEmpty(ByVal s As String) If (IsNull(s)) Then isNullOrEmpty = True ElseIf (Len(s) = 0) Then isNullOrEmpty = True End If End Function ' Process [Enter] and [Esc] keys for quick selection textbox. Private Sub txtBookmarkName_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Debug.Print KeyCode If (KeyCode = 13) Then ' Enter m_gotoInProgress = True cmdGoto_Click ElseIf (KeyCode = 27) Then ' Esc cmdCancel_Click End If End Sub ' Go to selected bookmark. Private Sub cmdGoto_Click() On Error GoTo cmdGoTo_Click_Finally If (IsNull(lstBookmarks.listIndex)) Then MsgBox "There is no any bookmarks selected", vbExclamation + vbOKOnly, "Warning" Return End If Selection.GoTo What:=wdGoToBookmark, Name:=lstBookmarks.List(lstBookmarks.listIndex) cmdGoTo_Click_Finally If (m_gotoInProgress) Then m_gotoInProgress = False DoEvents txtBookmarkName.SetFocus End If End Sub ' Close bookmarks selection form. Private Sub cmdCancel_Click() Me.Hide End Sub
Public Sub ShowBookmarksSelectionForm() frmSelectBookmark.Show End Sub
Your users could run the macro as is, but it'll be more convenient if you add it to the QAT as follows:
- Click the QAT drop-down (circled in Figure G), and choose More Commands.
- From the Choose commands from drop-down, select Macro.
- Select ShowSelectionBookmarksForm (Figure G), and click Add.
- Click Close.
Now, you're ready to access all those bookmarks with a few quick clicks. On the QTA, click the new macro button to open the UserForm, shown in Figure H. Select a bookmark, and click the Go To button to quickly access the selected bookmark.
Quickly display all of a document's bookmarks.
Shamil Salakhetdinov, a freelance software developer in St. Petersburg, Russia submitted the macro I used in this article. You can reach Shamil at email@example.com.
Send me your question about Office
I answer readers' questions when I can, but there's no guarantee. When contacting me, be as specific as possible. For example, "Please troubleshoot my workbook and fix what's wrong" probably won't get a response, but "Can you tell me why this formula isn't returning the expected results?" might. I'm not reimbursed by TechRepublic for my time or expertise, nor do I ask for a fee from readers. You can contact me at firstname.lastname@example.org.