How to Export Word Form Field Properties to Excel using VBA
Question details
The user needs to extract specific properties from form fields across multiple Word documents and compile them into an Excel spreadsheet.

- Product
- Word and Excel
- Device & OS
- not provided
- Scenario
- Gathering data properties such as field type, maximum length, width, and bookmark name from form fields across a batch of Word documents.
- Observed behavior
- Currently, the properties need to be extracted manually. The goal is to automate the extraction and export process to an Excel table using a VBA script.
Ensure that the Developer tab is enabled in your Word application ribbon and that you have basic familiarity with navigating the VBA Editor (ALT + F11).
Use VBA to Extract Form Field Properties to Excel
Run a VBA macro to loop through all form fields in a Word document and extract their properties into an Excel application instance.
You can utilize a VBA macro to read the properties of every form field within the active document. By iterating through the ActiveDocument.FormFields collection, you can capture the exact configuration of each field.
To process multiple files, this core script can be nested inside a batch processing loop that opens each document in a designated folder sequentially and outputs the data to an Excel table.
Press 'ALT + F11' in your word processor to open the Visual Basic for Applications (VBA) editor.
Click on 'Insert' in the top menu bar and select 'Module' to create a new blank script window.
Define a FormField object variable and loop through the collection using: 'For Each FF In ActiveDocument.FormFields'. Inside the loop, retrieve properties using 'FF.Type', 'FF.TextInput.Width', and 'FF.Name'.
Add code to create an Excel application object ('CreateObject("Excel.Application")'), add a new workbook, and assign the extracted form field values directly into the spreadsheet cells.
Press 'F5' or click the 'Run' button (green triangle) in the toolbar to execute the macro and generate your Excel table.

Extract Document Data Using Macros in WPS Writer
WPS Office offers a fully compatible Developer environment where you can run VBA macros just like in Microsoft Word. Automate your document processing, manage form fields, and export data seamlessly.
- 1. Enable the Developer Tab: Open WPS Writer, go to the Options menu, and customize the ribbon to ensure the Developer tab is checked and visible.
- 2. Launch the VBA Editor: Click on the Developer tab and select 'Visual Basic', or simply use the 'ALT + F11' keyboard shortcut.
- 3. Run Your Form Field Macro: Paste your form field extraction VBA code into a new module and hit 'Run' to seamlessly export the document properties.

Frequently Asked Questions
What are legacy form fields in a Word document?
Legacy form fields are interactive elements like text boxes, checkboxes, or dropdown lists that allow users to input data. They are accessed in VBA via the Document.FormFields collection.
Can I extract data from multiple Word documents automatically?
Yes, you can write a batch processing script in VBA that loops through all Word files in a specific folder, opens each one, reads the form field properties, and appends the extracted data to a single Excel sheet.
Why is my macro not reading the form fields?
Ensure that the document actually uses legacy form fields rather than newer Content Controls. If your document uses Content Controls, you must target the Document.ContentControls collection instead of FormFields.
Do VBA macros created in Word work in WPS Office?
Yes, WPS Office supports VBA. Most macros written for Microsoft Word, including scripts that iterate through form fields or interact with Excel, will run smoothly in the WPS Writer macro environment.




