Microsoft KB Archive/250432
Article ID: 250432
Article Last Modified on 6/17/2005
- Microsoft Word 2000 Standard Edition
This article was previously published under Q250432
When you record a macro to insert an AutoText entry containing formatting (for example, a frame or specific font formatting), Microsoft Word does not insert the specific formatting when you run the macro.
For example, the following recorded macro does not insert the formatting contained in the specified AutoText entry:
Sub InsertMyAutoText() Application.DisplayAutoCompleteTips = True NormalTemplate.AutoTextEntries("AutoTextName").Insert _ Where:=Selection.Range End Sub
NOTE: "AutoTextName" is the name of your AutoText entry.
The RichText property is not recorded automatically when you record the macro. You must manually add the RichText property to your macro code and set it to True.
For more information about the RichText property, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type RichText property in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:
212536 OFF2000: How to Run Sample Code from Knowledge Base Articles
To correct this problem, add the RichText property to your recorded macro. Your macro code should look similar to the following example:
Sub InsertMyAutoText() Application.DisplayAutoCompleteTips = True Normaltemplate.Autotextentries("AutoTextName").Insert _ Where:=Selection.Range, RichText:=True End Sub
For more information about creating and storing AutoText entries, click Microsoft Word Help on the Help menu, type Store and insert frequently used text and graphics in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
For more information about recording a macro, click Microsoft Word Help on the Help menu, type recording a macro in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.
For additional information about getting help with Visual Basic for Applications, click the article numbers below to view the articles in the Microsoft Knowledge Base:
212623 WD2000: Macro Programming Resources
226118 OFF2000: Programming Resources for Visual Basic for Applications
Additional query words: vb vba vbe
Keywords: kbmacro kbmacroexample kbprb kbdtacode kbpending KB250432