Macro-Inserted AutoText Doesn't Set Style

Written by Allen Wyatt (last updated May 25, 2019)
This tip applies to Word 97, 2000, 2002, and 2003


Glenn is inserting an AutoText entry into his document using a macro. When he inserts the entry manually (not from the macro), Word sets the style properly for the entry using the style (Heading 3) stored with the AutoText entry. But when he uses the macro to insert the AutoText entry, the inserted entry shifts to another style (Body Text).

The first thing to check is that there is really a style stored with the AutoText entry. In this case, the style is stored with the entry if the paragraph mark at the end of the text was selected when the entry was defined. (It probably is this way in Glenn's case since the style is set properly when manually inserting the AutoText, but it is still a good thing to check.)

Once you are sure that the style has been saved with the document, you need to take a look at your macro and how the AutoText entry is being inserted. If you have an AutoText entry named "MyText," the normal way to insert it is to use a macro line such as the following:

NormalTemplate.AutoTextEntries("MyText").Insert Where:=Selection.Range

If you want the formatting of the AutoText entry to be used, however, you need to make sure that the optional RichText parameter is used:

NormalTemplate.AutoTextEntries("MyText").Insert _
  Where:=Selection.Range, RichText:=True

Your AutoText should now be inserted exactly as you want it to be inserted.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (314) applies to Microsoft Word 97, 2000, 2002, and 2003.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Creating an AutoText List

The AUTOTEXTLIST field is one of those esoteric fields that you may know nothing about. The cool thing it does is allow ...

Discover More

Changing Built-in Word Commands

Want to replace Word's internal commands with your own macros? It's easy to do if you know the key discussed in this tip.

Discover More

Adding a Macro to the Quick Access Toolbar

The Quick Access Toolbar is a great place to put anything for which you want quick access. (Duh!) Here's how you can add ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More WordTips (menu)

Organizing AutoText Entries

Want to get more organized with your AutoText entries? Here's how you can take advantage of the organizational features ...

Discover More

Saving AutoText Entries with Each Document

AutoText can be a great way to add consistent, common text to a document. Unfortunately, you cannot save AutoText entries ...

Discover More

QuickWords in Word

WordPerfect users coming to Word may miss a feature called QuickWords. This tip examines some ways you can get around the ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is nine minus 5?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.