macros and autotext from a non normal.dot tamplate

K

kurt

Hello,

I'm trying to write a macro that inserts an autotext entry
from a template other than the Normal.dot.

In the code, NormalTemplate.AutoTextEntries("cbo").Insert
Where:=Selection.Range, _RichText:=True
when I try to replace Normal with the name of my global
template where the "cbo" autotext is found, I get an error
message.

In a macro,how can I tell Word to look on any other
template, or on all active templates to find autotexts?

Much appreciation!

Kurt
 
J

Jean-Guy Marcil

kurt was telling us:
kurt nous racontait que :
Hello,

I'm trying to write a macro that inserts an autotext entry
from a template other than the Normal.dot.

In the code, NormalTemplate.AutoTextEntries("cbo").Insert
Where:=Selection.Range, _RichText:=True
when I try to replace Normal with the name of my global
template where the "cbo" autotext is found, I get an error
message.

In a macro,how can I tell Word to look on any other
template, or on all active templates to find autotexts?

Much appreciation!

Normally we use the AttachedTemplate property to insert Autotext form the
template on which the current document is based:

'_______________________________________
Dim MyDoc As Document

Set MyDoc = ActiveDocument

MyDoc.AttachedTemplate.AutoTextEntries("cbo").Insert _
Where:=Selection.Range, RichText:=True
'_______________________________________

If you want absolute control and insert Autotext from any template it can be
done. However, the template must be active (opened, a document based on that
template is opened, it is a global template in the Start-up directory, etc.)

'_______________________________________
Dim MyTemplate As Template

Set MyTemplate = Templates("X:\Template1.dot")
MyTemplate.AutoTextEntries("cbo").Insert _
Where:=Selection.Range, RichText:=True
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
G

Guest

Thanks so much Jean-Guy! That worked perfectly.

Are you french, or quebecois perhaps? I speak french and
lived abroad, both in Paris and New Caledonia. I also
worked in Quebec for 8 months, and your name is quite
french sounding.

En tout cas, merci pour tout!

Kurt
 
J

Jean-Guy Marcil

(e-mail address removed) was telling us:
(e-mail address removed) nous racontait que :
Thanks so much Jean-Guy! That worked perfectly.

Are you french, or quebecois perhaps? I speak french and

The later...
lived abroad, both in Paris and New Caledonia. I also

Wow, would love to go to New Caledonia... any contracts over there?
worked in Quebec for 8 months, and your name is quite
Whereabouts?

french sounding.

Yep, that it is!
En tout cas, merci pour tout!

De rien!

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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