Lene Fredborg, DocTools, har modtaget den prestigefyldte pris som Microsoft Most Valuable Professional (MVP) i Microsoft Word – link til information om MVP Award'en på microsoft.com DocTools - dokumentautomatisering - add-ins, makroer og skabeloner til Microsoft Word (logo) Dokumentautomatisering
Add-ins & Makroer
Skabeloner
Til Microsoft Word
Dokumentautomatisering, skabeloner (templates), add-ins og makroer til Microsoft Word (grafik)



Hvis du tilmelder dig nyhedsbrevet, vil du få en e-mail, når der er nye tips om Word her på www.thedoctools.com eller på bloggen. Du kan framelde dig når som helst.


Bogmærk denne side | Tip en ven om DocTools


Søg thedoctools.com:

Custom Search


PDF til Word Konvertering



Konverter PDF til Word, Excel, PowerPoint mm.



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...



Copyright © 2006-2013 Lene Fredborg – DocTools ApS – alle rettigheder forbeholdt | Microsoft Word skabeloner (templates) – add-ins – VBA makroer | Spar tid og arbejd mere effektivt i Microsoft Word
Privat politik | Betingelser for brug | Bogmærk denne side | Tip en ven | Links | Kontakt
Valid HTML 4.01 Transitional – klik på ikonet for a validere denne side   Valid css information – klik på ikonet for at validere Style Sheetet for dette websted