Find Word Content Control Text by Tag, Title, or ID with VBA
Question details
The user wants to retrieve text from a Word content control using VBA by targeting the control's Tag, Title, or ID instead of its index.

- Product
- WPS Office Writer (Word VBA)
- Device & OS
- not provided
- Scenario
- The user is automating a Word document and needs a stable way to locate a specific content control even when controls are added, deleted, or reordered.
- Observed behavior
- Index-based references can change when controls are added or reordered; the user needs a stable Tag, Title, or ID lookup for the content control text.
Open the document in WPS Office Writer or Microsoft Word, enable the Developer tab, and open the VBA editor. Identify whether the target content control has a unique Tag, Title, or ID before writing the lookup code.
Retrieve Content Control Text by Title or Tag with VBA
Use SelectContentControlsByTitle or SelectContentControlsByTag when the control is identified by a title or tag. These methods return a collection, so check Count and iterate when titles or tags are not unique.
Titles and tags are not required to be unique, and the filtering methods are case-sensitive. Iterating the filtered collection is faster than looping through all content controls.
In WPS Office Writer or Word, click the Developer tab, then click Visual Basic, or press Alt+F11.
In the VBA editor, click Insert > Module to create a new standard module.
Paste a macro that calls ActiveDocument.SelectContentControlsByTitle("Your Title") or ActiveDocument.SelectContentControlsByTag("Your Tag"), checks .Count, and reads .Item(1).Range.Text.
Place the cursor in the macro and press F5, or click Run > Run Sub/UserForm.

Retrieve Text Using the Content Control Unique ID
Use ActiveDocument.ContentControls("ID").Range.Text when you know the unique ID. This is the most stable method because IDs do not shift when controls are added or reordered.
Assign Unique Titles or Tags and Retrieve the First Match
If you can set unique titles or tags, you can simplify lookup by assigning an identifier and then reading the first returned item.
Retrieve Word Content Control Text by Tag, Title, or ID in WPS Office
WPS Office Writer supports the Word VBA content control object model, so you can use tag, title, or ID lookups to return control text without relying on a shifting index. Open the VBA editor, insert a module, and run the lookup macro directly in WPS Office.
- 1. Open WPS Office Writer: Launch WPS Office Writer and open the .docx or .docm document that contains the content controls.
- 2. Open the VBA editor: Click the Developer tab and choose Visual Basic, or press Alt+F11.
- 3. Insert a module: In the VBA editor, click Insert > Module to create a standard module.
- 4. Add and run the lookup code: Paste a macro that uses ActiveDocument.ContentControls("ID"), SelectContentControlsByTitle, or SelectContentControlsByTag, then press F5.
- 5. Verify returned text: Use MsgBox or Debug.Print to confirm that the macro returns the content control text.

Frequently Asked Questions
How do I find the ID of a content control in Word VBA?
Run a VBA loop over ActiveDocument.ContentControls and print each control's .ID and .Title to the Immediate Window. For example: For Each cc In ActiveDocument.ContentControls: Debug.Print cc.ID, cc.Title: Next cc. Open the Immediate Window by pressing Ctrl+G in the VBA editor.
Are SelectContentControlsByTitle and SelectContentControlsByTag case-sensitive?
Yes. Both methods perform case-sensitive matching. If you need case-insensitive matching, iterate through ActiveDocument.ContentControls and compare cc.Title or cc.Tag using StrComp with vbTextCompare.
What happens if multiple content controls have the same title or tag?
SelectContentControlsByTitle and SelectContentControlsByTag return a collection of all matching controls. Check the Count property and use Item(1), Item(2), or a For Each loop to process each match.
Why should I avoid retrieving content control text by index?
Index-based references such as ActiveDocument.ContentControls(1) can change when controls are added, deleted, or reordered. A unique ID remains stable, and unique titles or tags are easier to maintain.
Can WPS Office Writer run Word content control VBA macros?
Yes. Open the document in WPS Office Writer, enable the Developer tab, click Visual Basic, and use the same Word VBA content control methods such as SelectContentControlsByTitle, SelectContentControlsByTag, and ContentControls("ID").




