How to Display a Selected Word Option Button Value Elsewhere Using VBA
Question details
The user wants to automatically display the text value of a selected option button (e.g., A, B, C, or D) in another part of a Word document through a bookmark and a REF field.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Creating an interactive form or template where a user's choice from a group of option buttons needs to be dynamically referenced or displayed in a different section.
- Observed behavior
- Standard REF fields cannot directly read an option button's selected state, and the GroupName property only groups buttons together without exposing the selected button's label.
Ensure that the Developer tab is enabled in your ribbon, as you will need access to ActiveX Controls and the VBA (Visual Basic for Applications) editor to implement this solution.
Use VBA to Write the Option Button Value to a Bookmark
Since standard fields cannot read ActiveX option button states directly, a VBA macro is required to detect the selection, update a bookmark with the button's label, and refresh the REF field.
By writing a simple click-event macro for your option buttons, you can push the caption of the selected button into a specific text bookmark. A REF field pointing to that bookmark will then display the value anywhere in the document.
Navigate to the Developer tab, click on Legacy Tools (or Controls), and insert ActiveX Option Buttons. Right-click each button, select Properties, and set the 'GroupName' property to the same value so they function as a mutually exclusive group.
Go to the location in your document where you want the value to appear. Type a placeholder space, highlight it, and go to Insert > Bookmark. Name the bookmark (for example, 'SelectedValue') and click Add.
Press Ctrl+F9 to insert empty field brackets. Inside the brackets, type 'REF SelectedValue'. Press F9 to update the field so it displays the contents of your bookmark.
Double-click one of the option buttons to open the VBA editor. Create a click event (e.g., Private Sub OptionButton1_Click) and write code to update the bookmark. Use a structure like: ActiveDocument.Bookmarks("SelectedValue").Range.Text = OptionButton1.Caption.
Add a line to your macro to automatically update the document fields so the change reflects instantly. Use 'ActiveDocument.Fields.Update' at the end of your click event. Repeat this code for the other option buttons in your group.
Create Dynamic Documents and Forms with WPS Writer
WPS Office provides robust support for document formatting, legacy form controls, and VBA macros. You can easily create interactive documents with option buttons and automate field updates using WPS Writer.
- 1. Enable the Developer Tab: Open your document in WPS Writer, go to Options, and ensure the Developer tab is enabled to access form controls.
- 2. Insert Option Buttons: Click the Developer tab and insert Option Buttons from the Forms section to create your multiple-choice group.
- 3. Use the VBA Editor: Press Alt+F11 to open the built-in VBA editor and write a short macro linking your buttons to a document bookmark.
- 4. Save as a Macro-Enabled File: Go to File > Save As and choose the Macro-Enabled Document (.docm) format to preserve your VBA code.

Frequently Asked Questions
Why doesn't the REF field update automatically when I click an option button?
REF fields in Word do not trigger an automatic update based on ActiveX control interactions. You must either update the fields manually by selecting the document text and pressing F9, or include a line in your VBA macro (ActiveDocument.Fields.Update) to trigger the refresh when the button is clicked.
How do I group option buttons so only one can be selected at a time?
To make option buttons mutually exclusive, right-click an option button and select Properties. Look for the 'GroupName' field and type a name (e.g., 'Group1'). Apply this exact same GroupName to all other option buttons you want linked together.
Is it possible to reference a selection elsewhere without using VBA?
Standard ActiveX option buttons do not expose their selected value to regular document fields natively. If you want to avoid VBA entirely, consider using Content Controls, such as a Drop-Down List, which can be natively mapped to XML or referenced elsewhere without relying on macros.




