How to Reset Form Fields in a Word Fillable Form

Creating a fillable form in Microsoft Word can greatly streamline data collection and processing. However, ensuring that users can easily reset and reuse the form is equally important. In this tutorial, we'll walk through the process of adding a Reset Form command button to your Word fillable form that clears all form fields with just a click.

How to reset form fields in a Word fillable form by adding an ActiveX command button that when a user clicks it, all of the form fields will be cleared out.

Step 1: Prepare Your Document

Before adding the reset button, ensure that your document is saved as a macro-enabled file type. To do this:

  1. Navigate to the "File" menu.

  2. Select "Save As."

  3. Choose a location to save your document.

  4. In the "Save as type" dropdown menu, select "Word Macro-Enabled Document."

  5. Click "Save" to confirm.

Step 2: Insert the Command Button

  1. Place your cursor where you want to insert the command button within your form.

  2. Go to the "Developer" tab in the Word ribbon.

  3. From the "Legacy Forms" dropdown menu, select "Command Button" under ActiveX controls.

  4. Double-click the button to open the Visual Basic for Applications (VBA) editor.

Step 3: Add VBA Code

  1. In the VBA editor, paste the provided code. This code is responsible for clearing form fields and is available below.

  2. Review the code to understand its functionality. It unprotects the document, clears form fields, and reprotects the document.

  3. Save and close the VBA editor.

Private Sub CommandButton1_Click()

    Dim cc As ContentControl

    Dim ff As field

   

    ' Unprotect the document to allow form field entry

    If ActiveDocument.ProtectionType <> wdNoProtection Then

        ActiveDocument.Unprotect

    End If

   

    ' Clear content control form fields

    For Each cc In ActiveDocument.ContentControls

        Select Case cc.Type

            Case wdContentControlText ' Text content control

                cc.Range.Text = ""

            Case wdContentControlComboBox ' Combo box content control

                cc.Range.Text = ""

            Case wdContentControlDate ' Date picker content control

                cc.Range.Text = "" ' Clear the date value by setting the Range.Text property to an empty string

            Case wdContentControlCheckBox ' Checkbox content control

                cc.Checked = False ' Uncheck the checkbox

        End Select

    Next cc

   

    ' Reset legacy form fields

    ActiveDocument.ResetFormFields

   

    ' Protect the document again if needed

    If ActiveDocument.ProtectionType = wdNoProtection Then

        ' Replace "YourPassword" with the actual password if your document is password-protected

        ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

    End If

End Sub

Step 4: Customize the Command Button

  1. Right-click the command button and select "Properties."

  2. In the properties window, rename the button to "Reset Form" in the caption field.

  3. Close the properties window.

Step 5: Finalize Document Protection

  1. Ensure you're in design mode by clicking the "Design Mode" button in the Developer tab.

  2. Navigate to the "Restrict Editing" option.

  3. Check the box to "Allow only this type of editing in the document" and select "Filling in forms" from the dropdown menu.

  4. Click "Yes, start enforcing protection" and choose NOT to set a password.

  5. Click "OK" to confirm.

Step 6: Test Your Form

  1. Enter data into your form fields.

  2. Click on the "Reset Form" button to clear all form fields.

  3. Verify that text boxes are empty, checkboxes are unchecked, and dropdown lists reset to their default selection.

Step 7: Additional Considerations

  1. If your form utilizes content control form fields instead of legacy form fields, the same reset functionality can be applied. The provided VBA code is designed to clear both types of form fields.

  2. Ensure that the first item in your dropdown lists is a default selection, as the reset function will revert to this option.

Conclusion Congratulations! You've successfully added a command button to your Word fillable form, allowing users to easily reset and reuse the form. This simple but powerful feature enhances the user experience and streamlines data management. Share this tutorial with others to help them optimize their form creation process. Be sure and subscribe to my YouTube Channel and check out the other Tutorials on my website for more helpful tips!

Previous
Previous

Adding a Reset Button to Your PDF Fillable Form

Next
Next

Creating Fillable Forms in Word for Mac