How to Extract Text from Word Table Cells and Content Controls with VBA
Question details
The user wants to extract standard text and text stored within content controls located inside Microsoft Word table cells using Visual Basic for Applications (VBA).

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Extracting data from Word forms, complex tables, and content controls for data processing or reporting purposes.
- Observed behavior
- The user needs a programmatic method to independently access and retrieve standard cell range text as well as the nested content control range text within those cells.
Before running any macros, ensure your document contains the target tables and content controls, and that you have enabled the Developer tab in your Word settings to access the VBA editor.
Use a VBA Macro to Iterate Through Cells and Content Controls
Write a VBA script to loop through the document's tables, extracting standard cell text while independently capturing any text inside nested content controls.
When extracting data from a Word document, regular text inside a cell and text inside a Content Control (like a text box or dropdown) require slightly different VBA range references. The macro needs to inspect each cell to see if it contains Content Controls, and if so, extract their specific values rather than just the generic cell text.
Press Alt + F11 in Microsoft Word to open the Visual Basic for Applications (VBA) editor.
Click on 'Insert' in the top menu and select 'Module' to create a blank script window for your macro.
Input a VBA macro that loops through ActiveDocument.Tables(1).Range.Cells. Within the loop, use Cell.Range.Text to retrieve the standard text, taking care to strip out the end-of-cell markers.
Inside the same loop, add a nested loop to iterate through Cell.Range.ContentControls. Use ContentControl.Range.Text to extract the specific values filled into the form fields.
Press F5 or click the 'Run' button to execute the script and output the extracted text to a message box, a new document, or an Excel spreadsheet.

Edit and Manage Word Documents Easily with WPS Office
If you frequently work with complex forms, tables, and document data extraction, WPS Office provides a lightweight, highly compatible, and free alternative to Microsoft Office. It supports common document formats and offers an intuitive interface for managing your daily document workflows without complex setups.
- 1. Download and Install: Visit the official WPS website to download and install WPS Office for free on your device.
- 2. Open Your Word Document: Launch WPS Writer and open your .docx file containing the tables and form data.
- 3. Manage Content Seamlessly: Easily view, edit, and organize table cells and text using WPS Writer's intuitive formatting tools.

Frequently Asked Questions
Why is there an extra character at the end of my extracted table cell text?
Word table cells include a special end-of-cell marker (a combination of ASCII 13 and ASCII 7). When extracting text using the Cell.Range.Text property in VBA, you must strip the last two characters from the resulting string to get only the visible text.
How do I extract data specifically from dropdown content controls?
To extract the selected value of a dropdown list content control, reference the control in your VBA loop and use the ContentControl.Range.Text property. You may also want to verify that the control is not currently displaying its default placeholder text before extracting.
Can I export the extracted Word table data directly to an Excel file using VBA?
Yes, you can use Word VBA to create an Excel Application object, open or add a new workbook, and write the extracted cell and content control values directly into the Excel worksheet's cells in an automated process.




