Word

Extracting AutoText entries without manually clicking the options

Ease of Use

Easy

Version tested with

97, 2003 

Submitted by:

lynnnow

Description:

This helps in pulling out all the AutoText entries without actually going to the AutoText menu and searching for the last output. 

Discussion:

I had some .dot files that had addresses in them and it was necessary to have these out of the template as a ready reference instead of guessing what the AutoText would be. Hence this method extracts all the AutoText entries within a .dot file and copies it into the ActiveDocument. You may have a ready-made template on your PC or a template that has been sent to you by someone which has AutoText that needs to be extracted and compiled. This will even work on your current Normal.dot file, or even any other template file that might have AutoText entries in it. After the data is out, you need to sort out the data you need. Since it required manual proofing of the extracted data, I didn't write any code for it. But it worked just fine for me and hence I've posted it here for anyone who needs it. 

Code:

instructions for use

			

Sub ExtractAutoText() Dim ATEntry As AutoTextEntry For Each ATEntry In ActiveDocument.AttachedTemplate.AutoTextEntries Selection.TypeText ATEntry.Value & vbCr Next ATEntry End Sub

How to use:

  1. Open any Word document.
  2. Press Alt + F11 to open the Visual Basic Editor (VBE).
  3. Right click on the project and select Insert -> New Module
  4. Copy the above code.
  5. Paste the code into the right-hand code window of the new module.
  6. Click Save.
  7. Close the VBE.
 

Test the code:

  1. Go to Tools-Macro-Macros and double-click ExtractAutoText.
 

Sample File:

AutoTextExmple.zip 11.21KB 

Approved by mdmackillop


This entry has been viewed 85 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express