John Clark
John.Clark at niagaracounty.com
Mon Jun 29 12:55:13 CDT 2009
This is VBA code to clear a bunch of objects on a MS Word form (2007). It is erroring out on, "For Each oFF In ActiveDocument.FormField" and says something like, "User defined type not defined" ??????? __________________________________________________________________________________ Public Sub ClearFields() 'MsgBox "Test" Dim oFF As FormField For Each oFF In ActiveDocument.FormField If TypeOf oFF Is TextBox Then oFF.Text = vbNullString ElseIf TypeOf oFF Is ComboBox Or TypeOf oFF Is ListBox Then oFF.ListIndex = -1 ElseIf TypeOf oFF Is OptionButton Then oFF.Value = False ElseIf TypeOf oFF Is CheckBox Then oFF.Value = vbUnchecked Else '... End If Next oFF End Sub __________________________________________________________________________________ The error did go away, if we changed "TypeOf oFF" to just "oFF", but then I get another error on the next line...it now doesn't seem to like "oFF.Text"...but that IS the value I am testing. Anybody have code to clear a form?