WD2000: Sample Visual Basic Macro to Type All AutoText Entries (221957)



The information in this article applies to:

  • Microsoft Word 2000

This article was previously published under Q221957

SUMMARY

The following macro inserts all of the AutoText entries in your Normal.dot (global template) file into a new document. The new document includes the name of each AutoText entry in bold letters, followed by the actual AutoText entry.

NOTE: You can quickly print a list of all AutoText entries without using this macro example. To do this, follow these steps:
  1. On the File menu, click Print.
  2. In the Print dialog box, change the Print what box to AutoText entries.
  3. Click OK.

MORE INFORMATION

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

Sub InsertAllAutoText()

Dim Entry As AutoTextEntry

Documents.Add

For Each Entry In NormalTemplate.AutoTextEntries

   ' Turn bold formatting on and insert the AutoText name
   Selection.Font.Bold = True
   Selection.TypeText Text:=Entry.Name

   ' Turn bold formatting off and insert AutoText entry
   Selection.Font.Bold = False
   Selection.TypeParagraph
   Entry.Insert Where:=Selection.Range, RichText:=True
   Selection.Range.Select
   Selection.TypeParagraph

   ' Insert a blank line between entries
   Selection.TypeParagraph
Next

End Sub
				

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbautotext kbdtacode kbhowto kbmacroexample kbProgramming KB221957