Heading

This is some text inside of a div block.
This is some text inside of a div block.
This is some text inside of a div block.
min read

Quick bookmarks

Word • Macros • Navigation
Peter Ronhovde
20
min read

Custom bookmarks are another way to navigate a document efficiently when writing and editing, but we can do better than using just the dedicated Bookmarks dialog. With that in mind, we create several macros to facilitate quickly setting and jumping between the bookmarks.

Thanks for your interest

This content is part of a paid plan.

Make using bookmarks faster

Bookmarks provide a convenient way to navigate between different regions of a document. Toward that goal, we create several custom macros to make setting or navigating with bookmarks much faster than even the Bookmarks dialog. After assigning the macros to their respective shortcuts, we can quickly set or redefine the bookmarks as needed to jump between different writing or editing locations.

These macros provide another tool bundle in a series targeting document navigation enhancements.

Doesn't Word already have …

I know this may initially feel like we’re reinventing the wheel, but as I’ve said before, we’re talking about streamlining our workflow making the whole writing and editing process faster.

GoTo dialog … nope

Well, yeah, technically to GoTo dialog exists in Word; but if you get paid to put words on a page, just no. We can trim our lawn with scissors too, but no one does it.

The GoTo tab of the overly general Find and Replace dialog is accessible via F5 in Windows or Mac, but it’s a prime example of how increased friction reduces its own utility. In the effort to make it apply to almost everything in addition to searching for text, it’s just clodgy (okay, not a real word), clunky, (hmmm, let me get my thesaurus) … uhhhh, as well as cumbersome and just plain awkward to use.

Using the bookmarks dialog

The dedicated bookmarks dialog is a better comparison for the efficiency increase of our current macros, so what steps would we need to accomplish the same tasks?

The standard shortcut Control+Shift+F5 in Word for Windows (or Command+Shift+F5 on Mac) feels a little awkward for my fingers, so I would probably redefine it (for Mac) or see a previous video for Windows.

Setting a new bookmark

If we manually set a new bookmark with the application, we need to do the following steps:

  1. Open the Bookmarks dialog with Control+Shift+F5 in Windows (or Command+Shift+F5 on Mac)
  2. Type the name of the new bookmark (okay but not fast)
  3. Press Return to add the bookmark (Add will probably be the default button) and again (or use the Escape key) to close the dialog

That's not horrible, but what about just Control+Alt+7 and done?

Access an existing bookmark

To jump to an existing bookmark using the Bookmarks dialog, the steps are a little faster.

  1. Open the Bookmarks dialog with Control+Shift+F5 in Windows (or Command+Shift+F5 on Mac)
  2. Select the appropriate bookmark from the list using the mouse (slow) or arrow keys
  3. Click the GoTo button or Press Return to jump to the bookmark and again (or use the Escape key) to close the dialog

Alternatively, double click the bookmark name, but using the mouse is slower than it feels in practice when a keyboard approach is available.

Sometimes the correct bookmark will already be selected, but it’s still more friction than necessary. I suspect these extra steps are just enough friction to hinder authors from actually using them regularly. The process is okay but a little clunky when you’re in the zone. With the macros below, we can accomplish the same thing by tapping Control+7 (or 4 or 1 for additional bookmarks), and we're there (wherever we set it).

What about the “goto last edit” shortcut?

As mentioned last article, Shift+F5 is a standard Word keyboard shortcut to cycle between the last several edits made in a document. While I'm a fan of the idea, it often counts individual characters as separate edits. Even just typing a single word somewhere else will fill up the "previous edits" list which significantly limits it practical utility. This feature is mostly only useful when a simple change is made. Otherwise, bake your own cookies because they're better.

Create the empty macro

A previous post covers creating an empty macro through the application's macro dialog or the record macro feature. When done, we’ll have something like the following:

Sub SetPrimaryBookmark()
' Set or redefine an editing bookmark in the document

End Sub
Sub GotoPrimaryBookmark()
' Jump to an editing bookmark in the document

End Sub

We'll need one for the setting and another for jumping to the bookmark location because Word only allows shortcuts to be assigned to macros with no parameters. I further have primary, secondary, and tertiary editing bookmarks to allow more flexibility, but define however many you want.

The single quote tells VBA the rest of the text on that line is a comment meant for human readers, but these macros are concise, so the descriptions are also. We start our macro steps on the empty line.

About VBA object thingies

VBA represents various document-related elements and content as internal "objects" which store related information or settings (called "properties"). They can also carry out actions on the properties or the associated document content via "methods". Generally speaking, the VBA object uses the same name as the document thing only capitalized.

What is a Range?

A Range (with a capital R) is a VBA generalization of a contiguous span of document content. Essentially, a Range is defined by Start and End positions (technically as a character count from the beginning of the document) that mark the spanned document content, but ranges also have other specific properties and methods to control itself or the document. We can declare Range variables and assign them to specific document ranges. Then we manipulate them and the content as needed to carry out the macro task(s). They are invisible to the user unless they are selected. An empty range has its Start and End positions equal.

What is the Selection?

A Selection (with a capital S) is a VBA object representing the selected content in the document. The Selection is like a special Range, but only one exists per document. It includes some specialized properties and methods to more conveniently manipulate the document or its own attributes.

An insertion point (the blinking I-bar waiting for you to type) is basically an empty selection where the Start and End positions are equal, so VBA treats it as a special case of the Selection. As the main point of user interaction, it is visible and usually kept in view on screen by Word unless the user uses to scroll bar or similar effect to look at different content.

What is a Bookmark?

A Bookmark (with a capital B) is VBAs version of the physical object we use to mark a page in a book, but in VBA it works more like a specialized Range. As such, it not only marks a document position, but it can also span a range of document content. Word includes some of its own hidden bookmarks (see the extended content below), but we can also set our own as needed.

Bookmarks collection

The Selection and any Range variables have a Bookmarks collection (basically a fancy list) that contains all the bookmarks spanned by the respective thing. We usually refer to the individual bookmarks in the collection by its plain text name, and they can be added to or deleted from the collection as needed.

What is the ActiveDocument?

Any document in Word is represented internally by a Document object. The current document with the focus (ready to interact with the user) has a shorthand name ActiveDocument. It is technically a member of the top-level (nothing above it) Application object, so we could verbosely refer to the active document like so:

Application.ActiveDocument ' Long way ...

Fortunately, we can omit Application since it is assumed.

ActiveDocument ' Application object is assumed

This reference is convenient because we do not need to know or look up the document name in the macro.

Adding a bookmark in VBA

The command to add a new bookmark via VBA is only one line, but we need to cover a couple topics first.

Work with the ActiveDocument bookmarks

We can access any pre-defined Word bookmark of the Selection through its Bookmarks collection:

' Bookmarks collection only contains spanned bookmarks
Selection.Bookmarks ' Not used

The Bookmarks collection of the Selection always contains the pre-defined bookmarks, but it only contains our own bookmarks that exist within its spanned content, but in this macro, we want access to all bookmarks in the document.

We’ll instead refer to the Bookmarks collection of the ActiveDocument. This collection allows us to access any Bookmark because the active document obviously includes the entire document.

' Get the collection of all bookmarks in the document
ActiveDocument.Bookmarks ' Not done ...

Set an editing bookmark

We set or redefine a bookmark using the Add method of the Bookmarks collection.

ActiveDocument.Bookmarks.Add ' Not done ...

Add adds a new bookmark to the collection, but if it already exists, it appears to redefine the bookmark (without crashing) based on the newly provided range.

Assign the bookmark name

We need to specify a unique plain text name of the new Bookmark using the Name option. This name is what we'll see in the Bookmarks list of the dialog.

' Create a bookmark using the current Selection (by default)
ActiveDocument.Bookmarks.Add Name:="BookmarkName"

We use a colon equals := symbol to assign arguments to command options. In this case, we assign the plain text name in double quotes (called a "string") with a maximum length of forty characters, but it cannot include any spaces (underscores "_" are okay). I use three regular editing bookmarks: PrimaryEdit, SecondaryEdit, and TertiaryEdit but any distinctive name(s) will work.

Assign the bookmark range

We need to specify a document Range for the bookmark. Of course, the range could span any content, but it could also be just a position (meaning it's empty with its Start and End positions equal). The command defaults to the range of the current Selection or the insertion point in the active document which we could specify using Selection.Range. The equivalent Add command would be:

' Range assignment based on the Selection is redundant (omitted below)
ActiveDocument.Bookmarks.Add Name:="PrimaryEdit", _
Range:=Selection.Range ' Same as default range

The underscore _ at the end of the first line is a line-continuation character that tells VBA to just continue the same command through the next line. It is not the same as including "_" in a variable or bookmark name, such as "Some_Bookmark", since the underscore is part of the plain text name in this context.

The Range of the current Selection is the default, so we can just omit it in the final macro.

Gotchas

What could go wrong?

To verify or not to verify?

Logically, we should verify whether the named bookmark already exists before trying to add it to the document again. The Microsoft Learn documentation for the Add method is terse but also ambiguous about whether adding a bookmark that already exists will cause an error. Testing indicates the Add method just redefines an existing bookmark, so we'll omit any more complicated conditional checks.

Final set bookmark macros

We're basically done already, so the final macro to set or reassign a bookmark is super short.

Sub SetPrimaryBookmark()
' Set or redefine an editing bookmark with the current Selection
ActiveDocument.Bookmarks.Add Name:="PrimaryEdit"
End Sub

Unfortunately, we need to define a separate bookmark macro for each one we use. I include a "primary editing" bookmark, but I added two more for "SecondaryEdit" and "TertiaryEdit". Of course, use whatever names you prefer. Here is an example of setting a secondary bookmark with a different name.

Sub SetSecondaryBookmark()
' Set or redefine an editing bookmark with the current Selection
ActiveDocument.Bookmarks.Add Name:="SecondaryEdit"
End Sub

All macros must have a unique name, but if we wish to assign them to shortcuts, they also cannot have any parameters (the parentheses after the names are empty). I assigned each respectively to Control+Alt+7 or 4 or 1, respectively, on the numpad in Windows or Command+Option+7 or 4 or 1 in Word for Mac.

These shortcuts are a little awkward, but I chose triplet of combinations that were grouped near each other on a full-sized keyboard but did not conflict with any other shortcuts. Although, I often override standard Word shortcuts if I do not find the action useful.

After being added, Bookmarks are supposed to remain defined in a document unless they are explicitly deleted, but sometimes they will mysteriously disappear. This probably occurs when the containing text is deleted without realizing it also contains a bookmark, but these macros easily reset them.

Go to a bookmark

Using the above macros, we can now quickly set a new bookmark during our editing sessions, so we need a corresponding macro to jump to it. We can use the GoTo method of the Selection which allows us to move the insertion point (the blinking I-bar waiting for new text) to any of several different document elements.

Selection.GoTo ' Not done ...

The initial range of the Selection is effectively ignored for the move. Of course, we want a bookmark, so we use the wdGoToBookmark constant from a table of document element items. This value is assigned to the What option.

Selection.GoTo What:=wdGoToBookmark ' Still not done ...

We need to specify a bookmark name in plain text. We used "PrimaryEdit" in the set macro above, so we assign this name to the obvious Name option.

Selection.GoTo What:=wdGoToBookmark, Name:="PrimaryEdit"

The double quotes are necessary for VBA to interpret the name as a "string" of plain text. The options were separated with a comma, so VBA does not complain at us.

Checking whether the bookmark exists

However, we have an immediate problem. What if the bookmark does not exist?

We need to check whether the bookmark exists before trying to access it, or the macro will crash and pop up and annoying error message. A rough conditional statement would be something like:

If the bookmarks exists Then
' Jump to the bookmark
Otherwise
' Do nothing
End the bookmark check

We only jump to the bookmark if it exists. If not, we just let the macro end without taking an action, so we can just omit that part. We use the Exists method of the Bookmarks collection to check whether the bookmark already exists in the document. Just provide the "PrimaryEdit" name of the bookmark in double quotes.

ActiveDocument.Bookmarks.Exists("BookmarkName")

The Exists method is True if the bookmark exists in the ActiveDocument and False if not. Since it gives us a Boolean result, we can use it directly in a conditional statement as our decision-making condition.

If ActiveDocument.Bookmarks.Exists("PrimaryEdit") Then
' Jump to the valid bookmark
Selection.GoTo What:=wdGoToBookmark, Name:="PrimaryEdit"
End If

Final go to bookmark macros

We basically just copy the above conditional statement into the go to bookmark macro skeleton.

Sub GotoPrimaryBookmark()
' Jump to an existing editing bookmark
If ActiveDocument.Bookmarks.Exists("PrimaryEdit") Then
Selection.GoTo What:=wdGoToBookmark, Name:="PrimaryEdit"
End If
End Sub

After the command, the bookmark's range will be selected either as a selection for any spanned text or just a new insertion point position if not.

I assigned these to Command+7 (or 4 or 1, respectively) in Word for Mac using the numpad. In Word for Windows, I use Control+7 (or 4 or 1, respectively), respectively. I used the numpad to keep the shortcuts together without conflicting with any of my other more important shortcuts.

See the earlier macro to set a quick bookmark. Each macro must have a unique name without any parameters (i.e., no variables are listed inside the parentheses) before we can assign them to shortcuts. I ended up with six distinct bookmark macros, three to set distinct editing bookmarks and three to jump to them, but use however many you think you will need.

Improvements

After jumping to a bookmark, the default behavior positions the selected range near the top of the screen. This works well much of the time, but depending on my monitor setup when I write, I prefer to keep at least two novel-sized pages fully on the screen, so the default page position after a jump actually disturbs my preferred page view.

The page adjustments below are definitely in the realm of personal preference. Feel free to skip the first method, but you should at least try the SmallScroll method in case you want to tweak the final position.

What is the ActiveWindow?

Similar to the ActiveDocument we used earlier, a Word Document has an ActiveWindow property in VBA. It allows us to refer to the Window object that currently has the focus without needing to know anything else. A Window has various methods to control the page view like setting the focus, controlling tool visibility, adjusting the page size or position on screen, etc. A typical long-winded reference could be:

Application.ActiveDocument.ActiveWindow ' Reference the current window

But we can just use ActiveWindow as shorthand.

ActiveWindow ' Reference the current window

VBA will assume the active window of the current active document.

Window position tweaks

After the bookmark jump, my personal implementation adds a couple steps to roughly center the page(s) on the screen. It's not perfect, and I even need to tweak the settings sometimes since it depends on whether the ribbon is visible, the window size, etc. While I don't like being vague in an article about a potential problem, it even seems to occasionally vary without a clear explanation.

If you're a perfectionist like a certain unnamed author, be aware that precisely controlling the document position on the screen is a little troublesome at times. While several tools are available to control the page view, it feels more like baking cookies while wearing winter gloves given how they respond to commands.

Word pre-defined page range

Word has a list of pre-defined bookmarks it uses to track a document internally. These are not visible in the bookmarks dialog, but we can access them in VBA. Specifically, we want to center a page vertically in the window, so the first step is to adjust the view based on the current page range. We can access this range using the pre-defined "\Page" bookmark with the Bookmarks collection of the Selection.

Selection.Bookmarks("\Page") ' Not done ...

We need the parentheses around the name because we need to reference the Range property of the bookmark to get its spanned document content.

Selection.Bookmarks("\Page").Range ' Range of current page

Now that we have it, what do we do with it?

Scroll the page view

We'll start with the ScrollIntoView method which will scroll a given range (or shape object) into view on screen no matter where it is positioned in the document.

ActiveWindow.ScrollIntoView ' Specify a range range to scroll

I specified the entire page range since I like to view the full page content on screen.

ActiveWindow.ScrollIntoView Obj:=Selection.Bookmarks("\Page").Range

We assign the desired range to the "Obj" option, but that's messy, so I omit Obj in the command below (VBA does not care since it is the first and only argument given). Depending on your preference, this will get us close to a centered page on the screen provided it fits, but we still need to tweak the page position to better center the text.

This is more of an adjustment for our macro since the Selection is already positioned on the current page based on the previous GoTo bookmark step.

Tweak the page view

Across various attempts, ScrollIntoView usually isn't quite right for me, so I often tweak the final position with the SmallScroll method.

ActiveWindow.SmallScroll Down:=7

This is equivalent to clicking the small arrows on the vertical scroll bar. The number of Down (or Up) steps entirely depends on your view, setup, and preference. My preference is to center the page content in the viewable area as closely as possible even if it clips the top and bottom of the visible page whitespace. I used about 7 steps down. We could also specify options Up, ToRight, or ToLeft as desired. Negative values are also allowed reversing the respective option direction.

There are several more window positioning commands like LargeScroll and PageScroll, but I'll try not to batter you with unused commands in this macro.

Final Macro

We only need to add two lines to the above go to bookmark variation. These adjustments should only be done if a bookmark is found, so they also go inside the conditional statement.

Sub GotoPrimaryBookmark()
' Jump to an existing editing bookmark
If ActiveDocument.Bookmarks.Exists("PrimaryEdit") Then
Selection.GoTo What:=wdGoToBookmark, Name:="PrimaryEdit"
' Roughly center page on screen fassuming a full page of text is visible
ActiveWindow.ScrollIntoView Selection.Bookmarks("\Page").Range
ActiveWindow.SmallScroll Down:=7
End If
End Sub

As mentioned previously, I like to write with novel-sized pages fully visible on the screen, so this works for me. I needed to adjust my page setup setting also, but that is a one-time action when a novel starts (I actually have a novel template document with most of the settings already in place). Some other approaches exist, and none of them are really the "best", so use what works for your setup.

Bookmark details

The final page view varies a little depending on things like whether the ribbon or horizontal ruler is visible, and it even feels like it varies at times in a way that is difficult to determine. Perhaps it's due to subtle changes in my own layout, but I also had other macros that position the window layout consistently as much as possible.

Technically, the bookmarks are supposed to remain defined in a document until they are deleted, but in my experience, they occasionally unintentionally disappear. This may occur when the local text is deleted taking the bookmark with it. Manually resetting a bookmark is a tad annoying, but the above macro resets it without minimal effort.

I'm not sure why VBA does not just have a "CenterPageVertically" method. Instead, it makes us work for this seemingly reasonable page view. Digging deeper and trying to bake our own is more challenging than it seems because accessing the real-time vertical size of some of the on-screen application elements is difficult to determine automatically especially in Word for Mac.

How do I use it?

If I’m about to move to make an edit somewhere else in the document, I’ll quickly hit Command+Option+7 to set an editing bookmark at my current location. I navigate to wherever and make the edit. Then I hit Command+7 to jump back to my original location. It's also convenient to place two bookmarks to jump back and forth if needed.

When specific locations are known, these quick bookmarks are faster, easier, and more precise than just clicking or tapping around. This is important to me because I build a running outline of tentative scenes in my novels with various notes as I write, and I sometimes feel the need to bounce around the novel and make notes or add interesting text snippets immediately lest I forget them.

Improvements

Since this revised go to macro make three adjustments to the page view each of which is immediately visible on screen, I would further add a step to disable screen updates until all changes are finished. This addition will eliminate any "screen flicker" issues from the rapid changes.

Personally, I prefer my bookmark to be set near the top of the page, so the page displays better by default. This is even more of a personal preference than the revised macro. While the logic to implement it is not difficult per se, it is outside the scope of this article.

Affiliate Links

If you're interested in using Word or another tool related to the article, check out these affiliate links. I may make a small commission if you purchase when using them, but there is no increase in cost for you, and it helps to support this site and associated content.

I've been using Microsoft for Business for commercial use (that's us writers) on one of the lower pricing tiers for years. I get to use my macros, have online storage, and don't have to worry about software updates.