AutoText Entries Word 2000

P

Peter Faulhaber

Hello,

How, in VBA, can I define an complete AutoText entry in VBA? Name and text
in VBA?

Thanks
 
J

Jean-Guy Marcil

Peter Faulhaber was telling us:
Peter Faulhaber nous racontait que :
Hello,

How, in VBA, can I define an complete AutoText entry in VBA? Name and
text in VBA?
To create an autotext from the currently selected text:

ActiveDocument.AttachedTemplate.AutoTextEntries _
.Add Name:="MyAutotext", Range:=Selection.Range

to create it in the attached template,
or to create it in Normal.dot:

NormalTemplate.AutoTextEntries _
.Add Name:="MyAutotext", Range:=Selection.Range

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

Peter Faulhaber

Jean-Guy,

than ks for your response. The code Range:=Selection.range is the text.
Instead of the selected text I want to also to put there text. so instead of
selected text in the document I want the text in VBA.

Can you help me?
 
J

Jean-Guy Marcil

Peter Faulhaber was telling us:
Peter Faulhaber nous racontait que :
Jean-Guy,

than ks for your response. The code Range:=Selection.range is the
text. Instead of the selected text I want to also to put there text.
so instead of selected text in the document I want the text in VBA.

Can you help me?

I do not think it can be done as the AutoTextEntries.Add method requires a
range.
I guess you could try feeding it a string:

ActiveDocument.AttachedTemplate.AutoTextEntries _
.Add Name:="MyAutotext", Range:=SomeStringVariable

But it will not work.
I think the reason is that Word stores more than just a string of text, it
stores formatting info with he AutoText. Word could not get formatting info
with a string.

I guess you could use a dummy/temp document or create a temporary range in
the current document, create the AutoText and then delete the
range/document.

--
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