logo
search
VBA & Macro Problems

How to Display a Selected Word Option Button Value Elsewhere Using VBA

Amos GikundaAmos Gikunda Oct 13, 2026 869 views

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.

How to Display a Selected Option Button Value Elsewhere in Word
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.
Before you start

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.

Solution 1Recommended

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.

1
Insert ActiveX Option Buttons

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.

2
Create a Target Bookmark

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.

3
Insert a REF Field

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.

4
Write the VBA Macro

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.

5
Update the Field via Code

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.

Recreating Bookmarks in VBA: When VBA writes text to a bookmark's range, it often deletes the bookmark itself. Make sure your macro re-adds the bookmark around the newly inserted text before updating the fields.

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. 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. 2. Insert Option Buttons: Click the Developer tab and insert Option Buttons from the Forms section to create your multiple-choice group.
  3. 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. 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.
Fully compatible with Microsoft Word macro-enabled document formats (.docm).Built-in Developer tab for inserting legacy form controls and ActiveX elements.Advanced VBA editor support for writing macros and automating custom tasks.Lightweight, fast, and features a familiar user interface for seamless migration.
QA img-9

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.