MSOffice Programming (Word) help

S

steven chong

Hi everyone,
Hope the MVPs for Office can help me out here.
Programming the word object is new to me. Basically, what i need to do is...
1) Open a template word document.
2) Menu->Insert->File (Another word Document)
3) Page Break
4) Repeat Step 2 for another file
5) Page Break
6) Save

i was succesfully in Inserting the new WordFile, but cant page break and
insert the next file. i always only get the latest file which i inserted
as the final product.
any samples, links which i can refer to will be very helpful

what i have now:

objWord = New Word.Application()
objWord.Documents.Open("C:\before.doc")
objWordDocument = objWord.ActiveDocument
With objWordDocument
.Range.InsertFile("C:\Word\Blah\File1.doc")
.Range.MoveEnd()
.Range.Collapse(0)
.Range.InsertBreak(7)
.Range.InsertFile("C:\Word\Blah\File2.doc")
.SaveAs("C:\after.doc")
End With

thanks in advance
 
C

Cindy Meister -WordMVP-

Hi Steven,
Hope the MVPs for Office can help me out here.
Programming the word object is new to me. Basically, what i need to do is...
1) Open a template word document.
2) Menu->Insert->File (Another word Document)
3) Page Break
4) Repeat Step 2 for another file
5) Page Break
6) Save

i was succesfully in Inserting the new WordFile, but cant page break and
insert the next file. i always only get the latest file which i inserted
as the final product.
any samples, links which i can refer to will be very helpful
Try

objWord = New Word.Application()
objWord.Documents.Open("C:\before.doc")
objWordDocument = objWord.ActiveDocument
With objWordDocument
.Range.InsertFile("C:\Word\Blah\File1.doc")
.Range.Collapse(0)
.Range.InsertBreak(7)
.Range.Collapse(0)
.Range.InsertFile("C:\Word\Blah\File2.doc")
.SaveAs("C:\after.doc")
End With


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top