Saving the cursor position in Word docs and templates

B

Black Lab

Our company templates are suppose to have the cursor open to a specific line
when the template is opened. Upon our last update, the cursor now opens to
line 1 instead of line 15. How do I get the cursor to open on a specific
line? Thanks
 
A

Aeneas

You can copy the following macros into each template. They will place the
insertion point at the same location it was positioned when you last closed
the document.

The first inserts a bookmark at the position of the insertion point (not at
the position of the last edit) every time you both issue the command to close
a document *and* confirm in the resultant message box that you want to save
the document. If you don't save the document when closing it the bookmark
will not be inserted or if it was inserted previously it will remain in the
previous location.

Trap: Saving the document, then closing it and saying you do not want to
save the document when prompted will not insert the bookmark or reposition it.

You must *not* change either macro name -- AutoClose and AutoOpen. They are
reserved for macros that automatically execute when you close any Word
document and open any Word document, respectively.

Macro #1
Sub AutoClose()
'To insert this bookmark each time, confirm that you want to save the
document 'when closing it

With ActiveDocument.Bookmarks
..Add Range:=Selection.Range, Name:="lastinsertionpointposition"
..DefaultSorting = wdSortByName
..ShowHidden = True
End With
End Sub

Macro #2:
Sub AutoOpen()
' goes to the bookmark set via the AutoClose macro if it exists, otherwise
moves ' ' to the beginning of the document

If ActiveDocument.Bookmarks.Exists("lastinsertionpointposition") = True Then
Selection.GoTo What:=wdGoToBookmark, Name:="lastinsertionpointposition"
End If
End Sub

To learn how to copy macros, read the following:
http://www.gmayor.com/installing_macro.htm
 
B

Black Lab

Is there anyone other way beside creating a Macro to do this? I have 60
templates to update.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top