WordBasic Macros to Write AutoText Entries to Text FileLast reviewed: July 30, 1997Article ID: Q91077 |
The information in this article applies to:
SUMMARYMicrosoft Word for Windows does not include an option to write the contents of your Autotext entries to a text file. This article contains two macros that you can use to export your Autotext entries to a text file named either GLOBAL.TXT (for global Autotext entries) or TEMPLATE.TXT (for template Autotext entries). Note: To generate a printed list of your AutoText entries instead of a text file, choose Print from the File command, select AutoText Entries in the Print What box, and choose the OK button.
MORE INFORMATIONNote: Microsoft provides this macro code "as is" without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
Global Autotext EntriesUse the following macro to write the global AutoText entries (entries from NORMAL.DOT and any global templates) to a text file named GLOBAL.TXT, stored in the current directory:
Sub MAINOpen "GLOBAL.TXT" For Output As #1 For count = 1 To CountAutoTextEntries() a$ = AutoTextName$(count) Print #1, "Autotext Name: ", a$ Print #1, GetAutoText$(a$) Print #1, ""Next count Close #1 End Sub Template Autotext EntriesUse the following macro to write the Autotext entries from the current template to a text file named TEMPLATE.TXT, stored in the current directory:
Sub MAINOpen "TEMPLATE.TXT" For Output As #1 For count = 1 To CountAutoTextEntries(1) a$ = AutoTextName$(count, 1) Print #1, "Autotext Name: ", a$ Print #1, GetAutoText$(a$, 1) Print #1, ""Next count Close #1 End SubThe CountAutoTextEntries function determines the number of Autotext entries for the specified context (global is the default context). The AutoTextName$ function returns the Autotext name, which the GetAutoText$ function uses to retrieve the contents of the Autotext entry.
Insert Autotext Entries into DocumentUse the following macro to insert all global AutoText entries into a new document window.
Sub MAINFileNewDefault For count = 1 To CountAutoTextEntries() a$ = AutoTextName$(count) Bold 1 : Insert a$ InsertPara Bold 0 : EditAutoText .Name = a$, .Insert InsertPara : InsertParaNext End Sub REFERENCESKbcategory: kbusage kbmacro KBSubcategory: |
Additional query words: 6.0 export autotext winword
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |