Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2007

Tip: Looking for answers? Try searching our database.

AutoText entries macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Macro''er - 08 Mar 2007 19:50 GMT
Hi.  I have 100 words I need to enter in the AutoText database in Word 2003.  
Can I create a macro instead of entering one by one in the database.  I have
a macro that i'm using for AutoCorrect (see code below).  Can I do something
like this for the AutoText?

AutoCorrect.Entries.Add Name:=    "AL", Value:="Alabama (AL)"

------------------------------------------
Smile...it is good for you!  :)
Greg Maxey - 08 Mar 2007 20:22 GMT
Make a two column table with headings "AutoText text"  and "AutoText
Name"

Put the 100 words (one word or phrases per row) in the left hand
column.  Put the names in the left hand column.

Run this code:

Sub MultiAutoTextGenerator()
Dim oDoc As Document
Dim i As Integer
Dim pEntryText As Range
Dim pEntryName As Range
Set oDoc = ActiveDocument
Selection.Tables(1).Cell(1, 1).Range.Select
Selection.Collapse
For i = 2 To oDoc.Tables(1).Rows.Count
   If oDoc.Tables(1).Rows(i).Cells(1).Range.Characters.Count > 1 Then
       Set pEntryText = oDoc.Tables(1).Cell(i, 1).Range
       pEntryText.End = pEntryText.End - 1
       Set pEntryName = oDoc.Tables(1).Cell(i, 2).Range
       pEntryName.End = pEntryName.End - 1
       oDoc.AttachedTemplate.AutoTextEntries.Add _
            Name:=pEntryName, Range:=pEntryText
   End If
Next i
End Sub

You could do better with your AutoCorrect code also. See:
http://gregmaxey.mvps.org/AutoCorrect_Generator.htm

On Mar 8, 2:50 pm, Macro''er <Macr...@discussions.microsoft.com>
wrote:
> Hi.  I have 100 words I need to enter in the AutoText database in Word 2003.  
> Can I create a macro instead of entering one by one in the database.  I have
[quoted text clipped - 5 lines]
> ------------------------------------------
> Smile...it is good for you!  :)
Helmut Weber - 08 Mar 2007 20:26 GMT
Hi,

>Hi.  I have 100 words I need to enter in the AutoText database in Word 2003.  
>Can I create a macro instead of entering one by one in the database.

Yes. But it seems,
AutoTextEntries.add
expects not only a name, but a range in addition.

So you have to put up some kind of list
containing a name and an according range.

Sure, doable.
With only a hundred I don't know whether its economical for you.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Jay Freedman - 08 Mar 2007 20:44 GMT
> Hi,
>
[quoted text clipped - 11 lines]
> Sure, doable.
> With only a hundred I don't know whether its economical for you.

It's already done. Download http://jay-freedman.info/autotextloader2.zip and
follow the instructions.

Signature

Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

Macro''''er - 08 Mar 2007 21:38 GMT
Thank you so much!  I'm loving this forum and learning so much from it!  
Thank you and all the MVPs!
Signature

Smile...it is good for you!  :)

> > Hi,
> >
[quoted text clipped - 14 lines]
> It's already done. Download http://jay-freedman.info/autotextloader2.zip and
> follow the instructions.
Greg Maxey - 08 Mar 2007 23:26 GMT
Jay,

I am sorry.  I was at work and forgot all about your excellent tool.  In
fact the link I referenced was to  my AutoCorrectGenerator that I adapted
from your code and posted last year.

I just updated my website to like to your AutoTextLoader from my
AutoCorrectGenerator tips page.

Cheers

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Thank you so much!  I'm loving this forum and learning so much from it!
> Thank you and all the MVPs!
[quoted text clipped - 18 lines]
>> and
>> follow the instructions.
Macro''''er - 08 Mar 2007 23:16 GMT
Hi Jay,

It's me again.  You don't by any chance have an autocorrect loader i can
use, do you?
Signature

Smile...it is good for you!  :)

> > Hi,
> >
[quoted text clipped - 14 lines]
> It's already done. Download http://jay-freedman.info/autotextloader2.zip and
> follow the instructions.
Greg Maxey - 08 Mar 2007 23:31 GMT
You didn't by chance read the first response to your question did you?

http://gregmaxey.mvps.org/AutoCorrect_Generator.htm
Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Hi Jay,
>
[quoted text clipped - 27 lines]
>> Email cannot be acknowledged; please post all follow-ups to the
>> newsgroup so all may benefit.
Macro''''er - 09 Mar 2007 00:46 GMT
I did, but I am so new at this creating macro and I'm hoping I can download a
file just like the AutoTextLoader Jay provided. The download includes the
userform and all.  Thank you!
-------------------------------
Smile...it is good for you!  :)

> You didn't by chance read the first response to your question did you?
>
[quoted text clipped - 30 lines]
> >> Email cannot be acknowledged; please post all follow-ups to the
> >> newsgroup so all may benefit.
Jay Freedman - 09 Mar 2007 04:36 GMT
You can download the AutoCorrect.dot template from
http://www.word.mvps.org/FAQs/Customization/ExportAutocorrect.htm.
That template contains a macro that can both create and reload a
document containing AutoCorrect entries.

If you need a version of that template for Word 2007, I've posted that
at http://jay-freedman.info/AutoCorrect2007.zip.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

>I did, but I am so new at this creating macro and I'm hoping I can download a
>file just like the AutoTextLoader Jay provided. The download includes the
[quoted text clipped - 36 lines]
>> >> Email cannot be acknowledged; please post all follow-ups to the
>> >> newsgroup so all may benefit.
Macro''''er - 09 Mar 2007 17:57 GMT
Thank you, it works really well!  

I have another question...can I leverage the AutoText Back up document to
find and replace in my active document?  Hope my question make sense.
Signature

Smile...it is good for you!  :)

> You can download the AutoCorrect.dot template from
> http://www.word.mvps.org/FAQs/Customization/ExportAutocorrect.htm.
[quoted text clipped - 51 lines]
> >> >> Email cannot be acknowledged; please post all follow-ups to the
> >> >> newsgroup so all may benefit.
Jay Freedman - 10 Mar 2007 01:49 GMT
To be honest, I can't quite grasp what you want to do. What does a
document full of AutoText entries have to do with Find/Replace? Can
you expand a bit on the purpose?

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

>Thank you, it works really well!  
>
[quoted text clipped - 56 lines]
>> >> >> Email cannot be acknowledged; please post all follow-ups to the
>> >> >> newsgroup so all may benefit.
Macro''''er - 10 Mar 2007 17:34 GMT
Sure.  I have a document with 2 columns that will consist of 500+ words or
phrase:

First column = Word ****(Plain text)
Second column = Word *******(formatted with bold, italics, with annotation)

I'm looking for a macro that will find the first column "Word" in my active
document and Replace with second column "Word" and format it Bold, Italics,
display the comment  and with highlight.

Thank you and hope my request makes sense.

Signature

Smile...it is good for you!  :)

> To be honest, I can't quite grasp what you want to do. What does a
> document full of AutoText entries have to do with Find/Replace? Can
[quoted text clipped - 67 lines]
> >> >> >> Email cannot be acknowledged; please post all follow-ups to the
> >> >> >> newsgroup so all may benefit.
Jay Freedman - 10 Mar 2007 21:57 GMT
A macro like that would be possible, although I can't say without
trying it whether the comment/annotation would come along.

There would have to be some preliminary code in the macro to open the
document containing the replacements (assuming the document to be
modified is already open), and set up some variables.

The core of the code would be a loop that steps through the rows of
the replacements table. For each row, it would run an inner loop that
uses the Find property of a Range object to search the active document
for the text from the first column. Each time it's found, the code
would replace the found text with the contents of the second column,
using the Range object's .FormattedText property.

It wouldn't be very hard to program, but it isn't something you can
just throw together -- there are usually some fiddly bits that need
tweaking after you test it with the real data.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

>Sure.  I have a document with 2 columns that will consist of 500+ words or
>phrase:
[quoted text clipped - 79 lines]
>> >> >> >> Email cannot be acknowledged; please post all follow-ups to the
>> >> >> >> newsgroup so all may benefit.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.