Open Doc and Go To

R

Raymond

Hello,

Hope I can get some instruction on how to set a template so that the new
document opens with the cursor located further on in the document at some
book mark. I think maybe using a Go To comand in a macro that runs when the
document starts, but I don't know how to do it...

Please help if you have suggestions...

Thanks!
Raymond
 
G

Greg Maxey

Insert a bookmark where you want the document to open. Lets call it
"OpenHere"

Use something like:
Sub AutoOpen()
ActiveDocument.GoTo What:=wdGoToBookmark, Name:="OpenHere"
'or
Dim oRng As Word.Range
Set oRng = ActiveDocument.Bookmarks("OpenHere").Range
oRng.Select
End Sub
 
J

Jay Freedman

Let's say you name the bookmark "StartHere". Then this code in the template
will place the cursor at the bookmark when a new document is created:

Sub AutoNew()
ActiveDocument.Bookmarks("StartHere").Range.Select
End Sub

The AutoNew macro name is special -- it runs automatically when a new
document is created from the template (and not at any other time, unless you
manually start it).

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
R

Raymond

This is great, just the thing i thought I should be looking for! Now i just
need to figure out how I put this code into my template. The only macros
i've been able to devise have been by recording the keystrokes...

Thanks so much for the info!

Raymond
 

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