Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get to the end of a word document 1

Status
Not open for further replies.

apchambers

Programmer
Jul 17, 2003
11
0
0
GB
Hi
I am using VBA from Access 2003 to automate the creation of mail merge documents. This is working fine but now I need to insert one document at the end of another. I cannot use Master/SubDocuments as that creates a blank page at the end (unless you can tell me otherwise) after the section break.
When you create a macro to do this using Word it creates the following code:

Selection.Endkey Unit:wdStory

when you go to the end of the file.

I can't find the syntax for this in VBA. Can anybody help?

 
That is the syntax. Selection.EndKey Unit:=wdStory moves the Selection to the end of the document - assuming you are in the MainStory.

What are you really asking?

Gerry
My paintings and sculpture
 
I'm trying to run it from Access 2003.
activedocument.selection etc and endkey is not a valid option
 
Ah.

Application.Selection.EndKey Unit:=wdStory

Selection is a property of the Application, not the ActiveDocument.

So if you have made a Word instance (say WrdApp), with early-binding, then it would be:

WrdApp.Selection.EndKey Unit:=wdStory

If you created it with late-binding, use:

WrdApp.Selection.EndKey Unit:=6

How Do I Get Great Answers To my Tek-Tips Questions? faq219-2884

Gerry
My paintings and sculpture
 
Many Thanks
That worked first time. Sometimes the obvious is the hardest to see!
Anne
 
Actually, next time, if it is a code question, could you please post in the VBA forum? That is the correct place for VBA code threads.

Thanks.

faq219-2884

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top