Office Settings & Configuration

Create Custom Word Documents with VBA UserForm Checkboxes and Bookmarks

Tauseeq MagsiTauseeq Magsi Nov 20, 2026 869 views

Question details

Create a Word UserForm that lets clients select products and generates a document containing the selected descriptions.

Create Custom Word Documents with VBA UserForm Checkboxes and Bookmarks
Product
Microsoft Word
Device & OS
not provided
Scenario
A client selects products in a VBA UserForm, and the template inserts the corresponding reusable content into a personalized document.
Observed behavior
The generated document contains only the product descriptions selected in the form.
Before you start

Use a desktop version of Word that supports VBA, and enable the Developer tab through Word's ribbon settings if it is not visible. Prepare a macro-enabled Word template and allow macros only if you trust the template.

Solution 1Recommended

Insert AutoText at bookmarks using UserForm checkboxes

Use this approach when clients can select multiple products and each description should appear at a specific location.

Store each description as an AutoText entry in the macro-enabled template. The example uses empty bookmarks as insertion points, so unselected descriptions do not need to be removed.

Use checkboxes for multiple selections. Option buttons are better suited to mutually exclusive choices.

1
Save the template

In Word, select File > Save As and save the file as a Word Macro-Enabled Template (.dotm).

2
Create AutoText entries

Select the first product description, then choose Insert > Quick Parts > AutoText > Save Selection to AutoText Gallery. Name it Product1 and choose your template in the Save in field. Repeat for Product2.

3
Add insertion bookmarks

Place the cursor at each intended insertion point and choose Insert > Bookmark. Create empty bookmarks named Product1 and Product2; do not leave the optional descriptions in the template body.

4
Build the UserForm

Choose Developer > Visual Basic, select the template project, and choose Insert > UserForm. Add checkboxes named chkProduct1 and chkProduct2 and a command button named cmdGenerate using the Toolbox and Properties window.

5
Add the insertion code

Double-click cmdGenerate in the form designer and add this code to its Click event: Private Sub cmdGenerate_Click() If Me.chkProduct1.Value Then ActiveDocument.AttachedTemplate.AutoTextEntries("Product1").Insert Where:=ActiveDocument.Bookmarks("Product1").Range, RichText:=True End If If Me.chkProduct2.Value Then ActiveDocument.AttachedTemplate.AutoTextEntries("Product2").Insert Where:=ActiveDocument.Bookmarks("Product2").Range, RichText:=True End If Unload Me End Sub

6
Run and test the form

In the Visual Basic editor, choose Insert > Module and add a macro that shows the form, such as Sub ShowProductForm(): UserForm1.Show: End Sub. Create a document from the template, choose Developer > Macros, and run ShowProductForm. Test different checkbox combinations.

Insert AutoText at bookmarks using UserForm checkboxes
Use matching names: The example assumes the document is attached to the template containing the AutoText entries and that the form, control, entry, and bookmark names match the code. It is intended for one-time insertion into a new document; bookmark ranges may change after insertion.
Free Microsoft Office alternative

Edit personalized Word documents with WPS Writer

WPS Writer is a free, lightweight alternative for creating and editing personalized documents in a familiar interface. Open existing Word files and continue working with minimal disruption; it does not fix or replace the Word VBA UserForm described above.

Edit personalized product descriptions in WPS WriterCompatible with Microsoft Word formats such as DOCX and DOCFamiliar document editing interfaceFree and lightweight for everyday document work
microsoft office alternative - wps office

Frequently Asked Questions

Should I use checkboxes or option buttons for product selections?

Add checkboxes from the UserForm Toolbox when clients can choose multiple products. Use option buttons when a group of choices should allow only one selection.

Where should I save the AutoText entries?

When you choose Insert > Quick Parts > AutoText > Save Selection to AutoText Gallery, select the macro-enabled template in the Save in field. The example code reads entries from the active document's attached template.

Why does the macro fail to find a bookmark or AutoText entry?

Check Insert > Bookmark for the exact bookmark name, and verify that the matching AutoText entry is saved in the document's attached template. The names in the code must match those items.

Can I use content controls instead of bookmarks?

Yes. Add content controls from the Developer tab and address them in VBA by a defined tag or title. They are useful when inserted content needs to remain easy to identify and update, but the insertion code must be adapted.