Attach template does not copy contents

S

Sukhi

Hello everyone
I create new document from custom build template -- "objWord.Documents.Add
Template:=strPath....

Then I need to add some more text to document depending on certain
conditions, which I saved as 3 different templates (couple of pages each).

When I attach template:--
objWord.selection.insertbreak wdpagebreak
objWord.ActiveDocument.AttachedTemplate = Template name

I dont see any of my text. However, if I am creating new document with any
of above templates, its ok.

I need to have all of it in one document, starting new page for each
template, because user just need to press print and post.
please be rest assured that your help is greatly appreciated.
 
S

Suzanne S. Barnhill

Attaching a template to a document provides styles, AutoText, macros, and
toolbars. It does not add document-level formatting (page layout) or
content. To get these, you must create a new document based on the template
and insert your file into it.
 
J

Jay Freedman

Hello everyone
I create new document from custom build template -- "objWord.Documents.Add
Template:=strPath....

Then I need to add some more text to document depending on certain
conditions, which I saved as 3 different templates (couple of pages each).

When I attach template:--
objWord.selection.insertbreak wdpagebreak
objWord.ActiveDocument.AttachedTemplate = Template name

I dont see any of my text. However, if I am creating new document with any
of above templates, its ok.

I need to have all of it in one document, starting new page for each
template, because user just need to press print and post.
please be rest assured that your help is greatly appreciated.

You misunderstood the meaning of "attach template". That operation
does not transfer any text from the template to an existing document;
all it does is make styles, autotext, and macros available.

Your macro should use the Documents.Add command to make a new document
based on the template, and then copy the text from that document to
your existing one; then you can discard the new document (close it
without saving it).

This article explains in more detail:
http://www.shaunakelly.com/word/attachtemplate/index.html

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

Cindy M -WordMVP-

Hi =?Utf-8?B?U3VraGk=?=,

When you attach a template, the only thing that happens is that your document
links to the AutoText, macros, toolbars and keyboard shortcuts stored in the
template. Optionally, you can also pick up the template's styles.

What does NOT happen (and there is no facility in Word for this) is bringing
across anything contained in the TEXT. That only happens when you create the
document from the template.

Perhaps what you need is InsertFile? Or to save the additional text as
AutoText entries and insert those?
I create new document from custom build template -- "objWord.Documents.Add
Template:=strPath....

Then I need to add some more text to document depending on certain
conditions, which I saved as 3 different templates (couple of pages each).

When I attach template:--
objWord.selection.insertbreak wdpagebreak
objWord.ActiveDocument.AttachedTemplate = Template name

I dont see any of my text. However, if I am creating new document with any
of above templates, its ok.

I need to have all of it in one document, starting new page for each
template, because user just need to press print and post.
please be rest assured that your help is greatly appreciated.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

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

Top