I'm trying to Reset Text Form Fields to their Default Text Values Within Range.
Every Text Form Field has Default Text entered in the Form Field properties.
The Sample code below will clear all FormFields of every type then for the Text Fields, ActiveDocument.FormFields("Boomark").Result = "DefaultText" will set the field to the Result Value.
But is there a way to simply have the macro reset to the Defalut Text already entered into the Form Field Properties without having to list every Field into the code with a result? (the list can get pretty long).
Also, What if I want to reset the form fields in a specific section of the document? I currently Highlighted a certain section and assigned the selection a Bookmark.
That Selection for instance can be bookmarked as ResetSelection1, another selecction as ResetSelection2, a third selection as ResetSelection3.
(I could also set Start/End Bookmarks: ResetSelection1Start/ResetSelection1End, ResetSelection2Start/ResetSelection2End, ResetSelection3Start/ResetSelection3End.)
Each ResetSelection1 has a Button assigned to reset the FormFields.
Pressing the Reset FormFields button in ResetSelection1 should reset all TextFormFields in that section to the value already within them in the properties, but it will leave ResetSelection2 & ResetSelection3 alone.
The code below Would reset all fields, and then with code each field can be updated.
Code: Select all
Sub ResetFormTextEntries()
Dim FF As FormField
For Each FF In ActiveDocument.FormFields
Select Case FF.Type
Case wdFieldFormTextInput
FF.Result = ""
Case wdFieldFormCheckBox
FF.CheckBox.Value = False
Case wdFieldFormDropDown
FF.DropDown.Value = 1
Case Else
' do nothing
End Select
Next FF
ActiveDocument.FormFields("TextFormField01").Result = "DefaultText01"
ActiveDocument.FormFields("TextFormField02").Result = "DefaultText02"
ActiveDocument.FormFields("TextFormField03").Result = "DefaultText03"
ActiveDocument.FormFields("TextFormField04").Result = "DefaultText04"
End Sub
Raudel