Hello,

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

Thanks

Re: AutoText Entries Word 2000 by Jean-Guy

Jean-Guy
Fri Jun 30 09:41:05 CDT 2006

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
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org



Re: AutoText Entries Word 2000 by PeterFaulhaber

PeterFaulhaber
Sun Jul 02 04:47:02 CDT 2006

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?

"Jean-Guy Marcil" wrote:

> 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
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org
>
>
>

Re: AutoText Entries Word 2000 by Jean-Guy

Jean-Guy
Mon Jul 03 10:14:46 CDT 2006

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
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org