Create several autotext entries

F

Fredrik E. Nilsen

Hi,

I'm not sure if this should be in the vba-group. Is there a way to add
several autotext entries automatically? Lets say I have written a few
pages and I want to get all all words with more than 6 letters as
autotext enties, without doing it manually with each word.
 
C

Cindy M.

Hi Fredrik,
I'm not sure if this should be in the vba-group. Is there a way to add
several autotext entries automatically? Lets say I have written a few
pages and I want to get all all words with more than 6 letters as
autotext enties, without doing it manually with each word.
Yes, this belongs in the VBA group. And yes, it should be possible. Very
roughly:

Sub BatchAutoText()
Dim templ as Word.Template
Dim doc as Word.Document
Dim wrd as Word.Range

'Specify the "container"
Set templ = NormalTemplate
Set doc = ActiveDocument
For each wrd in doc.Words
If Len(wrd) >= 6 Then
templ.AutoTextEntries.Add wrd.Text & "_AT", wrd
End If
Next
End Sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
T

Tony Jollans

What exactly do you hope to gain by this? You will end up with a lot of
autotexts that will be, for the most part, harder to use than just typing
the words.
 
F

Fredrik E. Nilsen

What exactly do you hope to gain by this? You will end up with a lot of
autotexts that will be, for the most part, harder to use than just typing
the words.

Yes. I'm aware of that. I've just been asked if it is possible. Open
Office has this feature built in and it drives me nuts if it it turned
on. It can on the other hand be useful if you are writing a document
with several long and difficult words. Make a new document, type (or
copy -> paste) the words you want as autotext, run the macro. Make
them available in your template and you're done.
 
F

Fredrik E. Nilsen

Sub BatchAutoText()
Dim templ as Word.Template
Dim doc as Word.Document
Dim wrd as Word.Range

'Specify the "container"
Set templ = NormalTemplate
Set doc = ActiveDocument
For each wrd in doc.Words
If Len(wrd) >= 6 Then
templ.AutoTextEntries.Add wrd.Text & "_AT", wrd
End If
Next
End Sub

Ah, thank you very much, I will try it.
 
S

Suzanne S. Barnhill

I think what you would want here, then, would be AutoCorrect entries rather
than AutoText.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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