VBA & Macro Problems

Create a Word VBA Macro to Clear Form Content Controls

Algirdas JasaitisAlgirdas Jasaitis Nov 20, 2026 869 views

Question details

Create a Word macro that clears or resets form content controls after completed data is emailed.

Create a Word VBA Macro to Clear Form Content Controls
Product
Microsoft 365 Word
Device & OS
not provided
Scenario
A user completes a Word form and emails its data without permanently saving the completed values in the original form.
Observed behavior
The desired form returns to its initial state after the email is sent, ready for another entry.
Before you start

Check that the form uses Word content controls rather than legacy form fields, and identify any locked, nested, or XML-bound controls that need special handling. Make sure your email macro captures the completed data before the reset runs.

Solution 1Recommended

Reset Word content controls with a VBA macro

Use this macro to clear common content controls in the active document and report controls that could not be reset.

The macro clears text and date values, unchecks check boxes, removes inline pictures, and selects the first entry in drop-downs and combo boxes. Add a blank or default first list entry if that is the desired reset state.

This example does not reset legacy form fields, ActiveX controls, or unsupported content control types. Locked, nested, or XML-bound controls may require changes specific to the form; clearing a rich-text control can also remove content nested inside it.

1
Open the VBA editor

In desktop Word, open the form and select Developer > Visual Basic. If Developer is hidden, enable it through File > Options > Customize Ribbon.

2
Insert the reset code

In the VBA editor, select Insert > Module in the form's macro-enabled document or attached template. Paste this code: Sub ClearFormControls() Dim cc As ContentControl Dim skipped As Long For Each cc In ActiveDocument.ContentControls If Not ResetOneControl(cc) Then skipped = skipped + 1 Next cc If skipped > 0 Then MsgBox skipped & " control(s) were unsupported or could not be reset." End If End Sub Private Function ResetOneControl(ByVal cc As ContentControl) As Boolean Dim i As Long On Error GoTo ResetFailed Select Case cc.Type Case wdContentControlText, wdContentControlRichText, wdContentControlDate cc.Range.Text = "" Case wdContentControlCheckBox cc.Checked = False Case wdContentControlDropdownList If cc.DropdownListEntries.Count = 0 Then Exit Function cc.DropdownListEntries(1).Select Case wdContentControlComboBox If cc.DropdownListEntries.Count > 0 Then cc.DropdownListEntries(1).Select Else cc.Range.Text = "" End If Case wdContentControlPicture For i = cc.Range.InlineShapes.Count To 1 Step -1 cc.Range.InlineShapes(i).Delete Next i Case Else Exit Function End Select ResetOneControl = True Exit Function ResetFailed: ResetOneControl = False End Function

3
Run and inspect the reset

Fill in a test copy of the form, then select Developer > Macros, choose ClearFormControls, and select Run. Check every control and investigate any skipped-control message.

4
Connect it to the email macro

In the VBA editor, add a call to ClearFormControls after your existing email routine has captured and sent the completed data successfully. Test the full workflow and verify the recipient receives the completed values before the form is cleared.

Reset Word content controls with a VBA macro
Preserve the original form: Consider storing the form and macro in a Word macro-enabled template (.dotm) and creating a new document from it for each submission. Review AutoSave and your email routine's attachment behavior: clearing the form does not undo an earlier save or remove a temporary file.
Free Microsoft Office alternative

Work with Word documents in WPS Writer

WPS Office is a free, lightweight alternative with a familiar interface for opening and editing Word documents. Its format support can help you move everyday documents between suites, but it does not fix or guarantee compatibility with Microsoft Word VBA form macros.

Open and edit Microsoft Word DOC and DOCX filesUse a familiar document-editing interface for everyday formsMove common Word documents into a lightweight office suiteUse core document tools for free
microsoft office alternative - wps office

Frequently Asked Questions

How do I make a drop-down return to a blank choice?

In Word, select the drop-down control and open Developer > Properties. Add a blank or suitable default entry as the first list item; the sample macro selects that first entry.

Will clearing the form erase data already sent by email?

No. The reset changes the active Word document, not an email already sent. Make sure the email macro captures the completed data before calling ClearFormControls.

Why does the macro report that a control could not be reset?

The control may be locked, unsupported, or otherwise unable to accept the reset operation. Select it in Word and check Developer > Properties, then review any document protection or XML binding.

Where should I save the macro so it remains available?

Save the code in a macro-enabled Word document (.docm) or a macro-enabled template (.dotm). A standard .docx file cannot store VBA macros.

Does this macro clear legacy form fields?

No. It loops through content controls. Legacy form fields require separate VBA code using the document's FormFields collection.