Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.pagelayout
ItsBarbara ItsBarbara is offline
external usenet poster
 
Posts: 22
Default Open with Cursor at bookmark in Header

I created a template in Word in which the user must enter his/her name in the
header. I would like for the document to open with the cursor in this spot
within the header. I created a bookmark in the header. How can I set it so
that when the document is created from the template, that the cursor
immediately goes to the bookmark in the header?
  #2   Report Post  
Posted to microsoft.public.word.pagelayout
Lene Fredborg Lene Fredborg is offline
external usenet poster
 
Posts: 1,291
Default Open with Cursor at bookmark in Header

In the template, you could save a macro named AutoNew and let the macro
display the header with the bookmark selected. However, I suggest another
approach that automatically inserts the user name. This requires that you can
rely on the name defined in Tools Options User Information tab being
correct.

You could then insert the AutoNew macro below in the template - the macro
will run when a new document is created, based on that template. In the
macro, change "UserName" to the name of your bookmark - the macro will
automatically update the bookmark with the currently defined user name:

Sub AutoNew()
Dim oRange As Range
Dim strBkmName As String

strBkmName = "UserName"

'To prevent error if bookmark is missing, check first
If ActiveDocument.Bookmarks.Exists(strBkmName) Then
Set oRange = ActiveDocument.Bookmarks(strBkmName).Range
'Insert the user name
oRange.Text = Application.UserName
'The bookmark is gone - recreate it
ActiveDocument.Bookmarks.Add strBkmName, oRange
Else
'What to do if the bookmark was not in the template?
'Insert code here
End If

'Clean up
Set oRange = Nothing
End Sub

If you cannot rely on the defined user name, you could change the macro so
that it displays an inputbox, asking about the user name. Please post back in
case you need an inputbox and need help on the VBA code.

For help on installing a macro, see:
http://www.gmayor.com/installing_macro.htm

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"ItsBarbara" wrote:

I created a template in Word in which the user must enter his/her name in the
header. I would like for the document to open with the cursor in this spot
within the header. I created a bookmark in the header. How can I set it so
that when the document is created from the template, that the cursor
immediately goes to the bookmark in the header?

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Go to bookmark in Header on Open ItsBarbara Microsoft Word Help 3 October 3rd 06 04:44 AM
New documents open with cursor above header, how to fix? ChBenson Microsoft Word Help 1 August 23rd 06 03:40 PM
All my new documents open with the cursor at the header location. linnaea Page Layout 6 January 15th 06 12:32 AM
Can I get the cursor to goto a bookmark on opening Marc R New Users 1 January 13th 06 05:17 AM
Header and Bookmark Tlar New Users 1 January 1st 05 08:41 PM


All times are GMT +1. The time now is 08:18 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"