Macro ready for use...
Macro – Create or edit AutoText via VBA
You may elsewhere find information telling that you can only create an AutoText via VBA if you first insert the desired content in a document.
Also, you may find information telling that you cannot change the content of an existing AutoText via VBA without first inserting the AutoText, then editing
the content and replacing the old AutoText with a new version. However, I have experienced that you can actually create an AutoText via VBA and set
the value to whatever string you want without first inserting the string in a document. Correspondingly, you can change the content of an existing
AutoText directly via VBA without first inserting the old version in a document.
How to create an AutoText without first inserting the content in a document
The idea is to first create the AutoText containing whatever is selected in the document (or you could define another range of your wish).
Then you can use the Value property of the AutoText to replace the content with the desired string.
An example of such macro can be viewed or downloaded via the links below.
How to edit the content of existing AutoTexts without first inserting the AutoTexts in a document
Corresponding to the procedure described above, you can change the contents of any existing AutoText – or you can replace a certain string in any AutoText.
Example: you want to replace the string "abc" in all AutoText entries in a specific template with "12345".
An example of such macro can be viewed or downloaded via the links below.
Note that the links below include both macros described above.
Related information
See general information about VBA macros and code snippets, incl. information about how to install macros.
Top of page
Back to Macros...
|