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