如果 CheckBox、DropDown 和 TextInput 对象的该属性值为 True,则指定的窗体域对象为有效的复选框窗体域。Boolean 类型,只读。
如果 CustomLabel 对象的该属性值为 True,则指定的自定义标签的各种属性(例如 Height、Width 和 NumberDown)共同构成有效的邮件标签。Boolean 类型,只读。
expression.Valid
expression 必需。该表达式返回“应用于”列表中的一个对象。
对于 CheckBox、DropDown 和 TextInput 对象,使用 FormField 对象的 Type 属性可在应用 CheckBox、DropDown 或 TextInput 属性之前确定窗体域的类型(wdFieldFormCheckBox、wdFieldFormDropDown 或 wdFieldFormTextInput)。该步骤可确保 FormField 对象为所需的类型。如果活动文档中第一个窗体域是一个复选框,则下列示例选中该复选框。
If ActiveDocument.FormFields(1).Type = wdFieldFormCheckBox Then
ActiveDocument.FormFields(1).CheckBox.Valid = True
End If
本示例在插入点添加一个文字型窗体域。由于 myFormField
是一个文字输入域而不是一个复选框,所以消息框显示“False”。
Selection.Collapse Direction:=wdCollapseStart
Set myFormField = ActiveDocument.FormFields.Add(Range:= _
Selection.Range, Type:=wdFieldFormTextInput)
MsgBox myFormField.CheckBox.Valid
本示例确定活动文档中第一个窗体域是否为文字型窗体域。如果 Valid 属性值为 True,则该文字型窗体域的内容更改为“Hello”。
If ActiveDocument.FormFields(1).TextInput.Valid = True Then
ActiveDocument.FormFields(1).Result = "Hello"
End If
如果名为“My Labels”的自定义标签的设置有效,则本示例用 My Labels 的设置在新文档中创建标签。
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