Application MailingLabel CustomLabels (CustomLabel) |
由“标签选项”对话框中的有效 CustomLabel 对象所组成的集合。该集合包括所有打印机类型(点阵、激光和喷墨打印机)的自定义标签。
使用 CustomLabels 属性返回 CustomLabels 集合。下面示例显示有效的自定义标签数目。
MsgBox Application.MailingLabel.CustomLabels.Count
用 Add 方法可创建自定义标签。下列示例先添加一个名为“My Label”的自定义邮件标签,然后设置页面大小。
Set ML = _
Application.MailingLabel.CustomLabels.Add(Name:="My Labels", _
DotMatrix:=False)
ML.PageSize = wdCustomLabelA4
用 CustomLabels(index) 可返回单独的 CustomLabel 对象,其中 index 是自定义标签的名称或索引序号。下列示例用名为“My Labels”的原有自定义标签创建一篇新文档。
Set ML = Application.MailingLabel
If ML.CustomLabels("My Labels").Valid = True Then
ML.CreateNewDocument Name:="My Labels"
Else
MsgBox "The My Labels custom label is not available"
End If
索引序号代表自定义邮件标签在 CustomLabels 集合中的位置。下列示例显示第一个自定义邮件标签的名称。
If Application.MailingLabel.CustomLabels.Count >= 1 Then
MsgBox Application.MailingLabel.CustomLabels(1).Name
End If