Create Custom Word Documents with VBA UserForm Checkboxes and Bookmarks
Question details
Create a Word UserForm that lets clients select products and generates a document containing the selected descriptions.

- 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.
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.
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.
In Word, select File > Save As and save the file as a Word Macro-Enabled Template (.dotm).
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.
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.
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.
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
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.

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.

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.




