Word

Step through bookmarks in a document

Ease of Use

Easy

Version tested with

2000 

Submitted by:

mdmackillop

Description:

Use a shortcut key to step through bookmarks to insert text. 

Discussion:

If you need the ability to edit existing text while wanting to step to the next position for text insertion, this macro allows you to use an unprotected document with Bookmarks rather than a protected document with FormFields. 

Code:

instructions for use

			

Sub GoToNextBookMark() Dim Rng As Range, MyRng As Range Set Rng = ActiveDocument.Range Selection.MoveRight Unit:=wdCharacter, Count:=1 Set MyRng = ActiveDocument.Range(Start:=0, End:=Selection.Range.End) If Rng.Bookmarks.Count = MyRng.Bookmarks.Count Then Exit Sub 'or 'If Rng.Bookmarks.Count = MyRng.Bookmarks.Count Then ' Rng.Bookmarks(1).Select ' Exit Sub 'End If Rng.Bookmarks(MyRng.Bookmarks.Count + 1).Select End Sub

How to use:

  1. Paste the code in your Normal.dot (or other Global template)
  2. Assign a keyboard shortcut to the sub.
 

Test the code:

  1. Open/create a document and add bookmarks where text insertion is required.
  2. Press the shortcut key (F2 in the sample), to move the insertion point to the next bookmark.
  3. The code contains commented options either to stop or to return to the first bookmark after the last bookmark is reached.
 

Sample File:

bookmarks.zip 5.28KB 

Approved by mdmackillop


This entry has been viewed 108 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express