W
Worsty
I have the following code in my OnOpen event of my word document
form. As long as you answer "Yes" to the msg box the code works fine,
but if you say no, then it exposes rows in my form that contain VBA
buttons and radio buttons.
Can anyone help me out with how to fix this?
Thanks so much....
Here is the code:
Dim myFormField As FormField
Dim aDoc As Document
Dim response
Dim msg As String
Set aDoc = ActiveDocument
msg = "Do you want to clear all FormField results?"
response = MsgBox(msg, vbYesNo)
If response = vbYes Then
For Each myFormField In aDoc.FormFields()
Select Case myFormField.Type
Case 70 ' text
' checks to see if there is default text
' if yes, removes user inout and
' reverts to default; if no, removes user input
If myFormField.TextInput.Default <> "" Then
myFormField.Result = myFormField.TextInput.Default
Else
myFormField.Result = ""
End If
Case 71 ' check
myFormField.Result = False
Case 83 ' dropdown
myFormField.DropDown.Value = 1
End Select
form. As long as you answer "Yes" to the msg box the code works fine,
but if you say no, then it exposes rows in my form that contain VBA
buttons and radio buttons.
Can anyone help me out with how to fix this?
Thanks so much....
Here is the code:
Dim myFormField As FormField
Dim aDoc As Document
Dim response
Dim msg As String
Set aDoc = ActiveDocument
msg = "Do you want to clear all FormField results?"
response = MsgBox(msg, vbYesNo)
If response = vbYes Then
For Each myFormField In aDoc.FormFields()
Select Case myFormField.Type
Case 70 ' text
' checks to see if there is default text
' if yes, removes user inout and
' reverts to default; if no, removes user input
If myFormField.TextInput.Default <> "" Then
myFormField.Result = myFormField.TextInput.Default
Else
myFormField.Result = ""
End If
Case 71 ' check
myFormField.Result = False
Case 83 ' dropdown
myFormField.DropDown.Value = 1
End Select