Select and copy from a attached template

C

camilla

Hi
I have a template with refernce to another template which contains different
sections. I want to select one of teh secions, copy and paste it in to the
document based on the first template. I attache the second template with "
Set vbProj = ActiveDocument.VBProject
vbProj.References.AddFromFile "C:\Mallar\Samlingsmall.dot"" in an
autonewmacro.
I guess I need to start with something like this:
For x = 1 To Word.Templates.Count
If Templates(x).Name = "samlingsmall.dot" Then
num = x
Exit For
End If
Next x

and then

templates(num).????? (the code to select the section) but I cant find out
the code.
Does anyone know how I can do that?

Regards
Camilla
 
J

Jezebel

This approach won't work. Adding the template to the project's references
makes its macro code available to the project. It doesn't add the template
to the Templates() collection, nor provide a way to access the content of
the template. Nor could you use the templates collection anyway -- templates
are not loaded as documents.

What you need to do is open the template as a document, copy what you need,
then close it. The fact that it's a template rather than an ordinary
document makes no difference for this purpose.

Dim MyDoc as Word.Document
Set MyDoc = Documents.Open("C:\Mallar\Samlingsmall.dot")
.....

etc
 
W

Word Heretic

G'day "camilla" <[email protected]>,

Unfortunately Jez is an ignorant beginner hack whose methods are oft
fraught with failure, please ignore him.

If the template is already loaded into the templates collection you
get some nasty side effects from loading it as he suggests.

What you have here is a classic case of shared boilerplate. What you
should do is make your own global template and store it in there as an
autotext entry. This makes it dead easy to reference it in both
places.

I go into boilerplate issues and the means of solving them quite
extensively in my Word Spellbook, available for sale from either of my
websites - see the very bottom of the message for one, or use my email
address root for the new one.



camilla said:
Hi
I have a template with refernce to another template which contains different
sections. I want to select one of teh secions, copy and paste it in to the
document based on the first template. I attache the second template with "
Set vbProj = ActiveDocument.VBProject
vbProj.References.AddFromFile "C:\Mallar\Samlingsmall.dot"" in an
autonewmacro.
I guess I need to start with something like this:
For x = 1 To Word.Templates.Count
If Templates(x).Name = "samlingsmall.dot" Then
num = x
Exit For
End If
Next x

and then

templates(num).????? (the code to select the section) but I cant find out
the code.
Does anyone know how I can do that?

Regards
Camilla

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
Email (e-mail address removed)
Products http://www.geocities.com/word_heretic/products.html

Replies offlist may require payment.
 

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