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. Create a reset form button in Word that will work to clear both Legacy form fields and Content Control form fields. We will insert a command button on our form and then program the button with the VBA code below. This button will uncheck a checked box, clear text from a text box and reset drop-down lists to the initial value. This Reset Form button will allow users to clear existing data that had been filled into the form so they can quickly and easily re-use the form like new. The Reset button is helpful when saving your form document as a Template file type will not support other features in the form.
Here is the VBA Code we used in our Reset Form button (notice two areas where I indicate you have to replace and insert angled brackets as the YouTube Description doesn't allow those characters):
Private Sub CommandButton1_Click()
Dim cc As ContentControl
Dim ff As field
' Unprotect the document to allow form field entry
If ActiveDocument.ProtectionType [Insert Angled Brackets] 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
Private Sub CommandButton1_Click()
Dim cc As ContentControl
Dim ff As field
' Unprotect the document to allow form field entry
If ActiveDocument.ProtectionType [Insert Angled Brackets] 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
TIMESTAMPS ⏰
00:00 Reset Form Button in Word
00:14 Legacy & Content Control Form Fields
00:26 Prepare Form for Reset Button
01:02 Insert Reset Form Button & VBA Code
02:12 Format Reset Form Button
02:34 Test the Reset Form Button
03:56 Reset Content Control Form Fields
COURSE 🎒
Create Fillable Forms, Surveys & Questionnaires in Microsoft Word like a Pro: • Creating Fillable Forms in Microsoft ...
WATCH NEXT 📺 Make Fillable Form Reusable in Word: • How to Make Fillable Forms Reusable i...
CHANNEL LINK 📺
/ @sharonsmith
Visit my Channel page on YouTube to see all my videos, playlists, community posts and more!
TEMPLATES 📄
Check out my helpful list of templates available for purchase: https://creatoriq.cc/43c51cv
Thank you for supporting my channel! 🌟
FREE DOWNLOADS ⬇️
✦ Visit https://mailchi.mp/6a0859ea0844/sharo... to sign-up for my e-mail list and get FREE downloads of super helpful spreadsheet formulas, dashboards and Org Chart templates for HR professionals.
CONNECT WITH ME 📎
Visit my website: https://www.sharonsmithhr.com for more information, tools and resources.
LinkedIn: / sharonsmithhr
Twitter: / sharonsmithhr
Instagram: / sharonsmithlearning
Facebook: / sharonsmithlearning