WordBasic Macros to Write AutoText Entries to Text File

Last reviewed: July 30, 1997
Article ID: Q91077
The information in this article applies to:
  • Microsoft Word for Windows, version 6.0

SUMMARY

Microsoft 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 INFORMATION

Note: 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 Entries

Use 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 MAIN
Open "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 Entries

Use 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 MAIN
Open "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 Sub

The 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 Document

Use the following macro to insert all global AutoText entries into a new document window.

Sub MAIN
FileNewDefault For count = 1 To CountAutoTextEntries()
 a$ = AutoTextName$(count)
 Bold 1 : Insert a$
 InsertPara
 Bold 0 : EditAutoText .Name = a$, .Insert
 InsertPara : InsertPara
Next
End Sub

REFERENCES

Kbcategory: kbusage kbmacro KBSubcategory:


Additional query words: 6.0 export autotext winword
Version : 6.0
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.