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 Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word automation, merge 2 templates into one doc

Status
Not open for further replies.

MossNelson

Programmer
Oct 30, 2003
26
US
I have a Word automation program which creates a document using a .dot template and bookmark fields from within a program. This works Ok.

Would like to use a second .dot template which would serve as a cover sheet and to merge the two documents into a single .doc

How can I accomplish this?

-Nelson

 
Create the two documents separately based on their templates, then copy and paste from one to the other.

Tamar
 
Tamar,

Thanks for the reply. How would I select the entire page based on the first .dot programmaticaly ?

By the way, what I'm trying to do here is provide an option to any existing letter for a fax cover page.

-Nelson
 
This will create a file from a template,copy the contents of the file, add another document, and past the contents into it. Needs tweaking to get to your goal.

loWord = Createobject("word.application")
loWord.Visible=.T.
loDoc = loWord.documents.add(<document template here>)
lodoc.content.copy()
lodoc2 = loWord.documents.add()
loWord.Selection.Paste()
 
>>> Needs tweaking to get to your goal <<<
You're right about that however, the copy & paste method may come in handy.

For example, a problem that I am encountering is that template 2 has a header but template 1 does not. Using template 2 as the basis document causes the header to appear on all pages. I will keep at it.
 
To keep the header only in the one document, you'll need to insert a section break before adding the second document. Make sure that you're set for separate headers and footers.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top