Office Settings & Configuration

Insert a Word AutoText Entry at a Bookmark Using VBA

Chanuka GeekiyanageChanuka Geekiyanage Nov 25, 2026 868 views

Question details

Insert a named AutoText entry at a Word bookmark using VBA while preserving the bookmark.

Insert a Word AutoText Entry at a Bookmark Using VBA
Product
Microsoft Word
Device & OS
not provided
Scenario
A macro needs to insert an AutoText entry stored in a specific template at a named bookmark.
Observed behavior
Calling InsertAutoText on the selection may fail when Word is not searching the template that contains the entry, and insertion can replace the original bookmark.
Before you start

In Word, open the document and use Insert > Bookmark to confirm the bookmark name. Identify the template containing the exact AutoText entry name, and enable macros only if the document and code are trusted.

Solution 1Recommended

Insert AutoText from its source template and recreate the bookmark

Use this method when you know the bookmark name, AutoText name, and template that stores the entry.

The macro inserts the entry at the bookmark range using the specified template. It then adds the bookmark again around the inserted range.

1
Check the AutoText entry

In the document, type the exact AutoText name and press F3 to test whether Word can insert it manually. If it does not insert, check which template contains the entry.

2
Add the VBA procedure

Open Developer > Visual Basic, choose Insert > Module, and paste: Sub AutoTextToBM(strBookmark As String, sourceTemplate As Template, strAutoText As String) Dim rng As Range On Error GoTo ExitHandler Set rng = ActiveDocument.Bookmarks(strBookmark).Range Set rng = sourceTemplate.AutoTextEntries(strAutoText).Insert(Where:=rng, RichText:=True) ActiveDocument.Bookmarks.Add Name:=strBookmark, Range:=rng ExitHandler: End Sub

3
Call the procedure

In the same module, add a calling macro for an entry stored in the document's attached template: Sub InsertMyAutoText() AutoTextToBM "SubAttorneysToAct", ActiveDocument.AttachedTemplate, "POASattJointlyOrSeverally" End Sub Replace the bookmark and AutoText names with your exact names. If the entry is stored elsewhere, pass the Template object for that template instead.

4
Run and verify

Place the cursor inside InsertMyAutoText in the VBA editor and select Run > Run Sub/UserForm. Return to Word and use Insert > Bookmark to confirm that the bookmark still exists around the inserted content.

If nothing is inserted: The error handler exits silently. Check that the bookmark exists and that the named AutoText entry is in the template passed to the procedure. Save the code in a macro-enabled document or template if you need to keep it.
Free Microsoft Office alternative

Edit Word documents with WPS Writer

WPS Office is a free, lightweight alternative with a familiar interface and Microsoft Office format compatibility for an easier move between office suites. The Word VBA procedure above is specific to Microsoft Word; WPS is not presented as a fix for it.

Work with Word documents in WPS WriterOpen and edit Microsoft Word DOC and DOCX filesUse a familiar interface for everyday document editingMove between office suites with compatible document formats
microsoft office alternative - wps office

Frequently Asked Questions

Why does the macro insert nothing?

The bookmark or AutoText entry may not exist under the supplied name, or the entry may be in a different template. Check Insert > Bookmark and pass the template that contains the entry. The sample error handler exits without displaying an error.

How can I test an AutoText entry before running the macro?

Type the exact entry name in Word and press F3. If it does not insert, check that the entry is available from the relevant template; the macro can reference that template directly.

Why does the macro add the bookmark again?

Inserting content can replace the original bookmark range. Bookmarks.Add recreates the named bookmark using the range returned by AutoTextEntries.Insert.

Can I use an AutoText entry from a template other than the attached template?

Yes. Pass the Template object for the template containing the entry as the sourceTemplate argument instead of ActiveDocument.AttachedTemplate.