Valid Property
Applies To
CheckBox object, CustomLabel object, DropDown object, TextInput object.
Description
CheckBox, DropDown, or TextInput object: True if the specified form field object is a valid check box form field, drop down form field, or text form field. False if it isn't valid. Read-only Boolean.
CustomLabel object: True if the various properties (for example, Height, Width, and NumberDown) for the specified custom label work together to produce a valid mailing label.
Remarks
Use the Type property of the FormField object to determine the type of form field (returns wdFieldFormCheckBox, wdFieldFormDropDown, or wdFieldFormTextInput) before applying the CheckBox, DropDown, or TextInput property. This precaution ensures that the FormField object is the expected type. If the first form field in the active document is a check box, the following example selects the check box.
If ActiveDocument.FormFields(1).Type = wdFieldFormCheckBox Then
ActiveDocument.FormFields(1).CheckBox.Value = True
End If
See Also
Type property.
Example
This example determines whether the first form field in the active document is a text form field. If the Valid property is True, the contents of the text form field are changed to "Hello."
If ActiveDocument.FormFields(1).TextInput.Valid = True Then
ActiveDocument.FormFields(1).Result = "Hello"
End If
This example adds a text form field at the insertion point. Because myFormField isn't a valid check box form field, the message box displays "False."
Selection.Collapse Direction:=wdCollapseStart
Set myFormField = ActiveDocument.FormFields.Add(Range:=Selection.Range, _
Type:=wdFieldFormTextInput)
MsgBox myFormField.CheckBox.Valid
If the settings for the custom label named "My Labels" are valid, this example creates a new document of labels using the My Labels settings.
addr = "James Allard" & vbCr & "123 Main St." & vbCr _
& "Seattle, WA 98040"
If Application.MailingLabel.CustomLabels("My Labels").Valid = True Then
Application.MailingLabel.CreateNewDocument _
Name:="My Labels", Address:=addr
End If