CustomLabel 对象

         
Application
MailingLabel
CustomLabels (CustomLabel)

代表一个自定义的邮件标签。CustomLabel 对象是 CustomLabels 集合的元素。CustomLabels 集合包括了“标签选项”对话框中列出的所有自定义邮件标签。

使用 CustomLabel 对象

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

注意   CustomLabel 对象在 CustomLabels 集合中按字母顺序排序,它们的索引序号按集合内容的改变而动态重新赋值。因此根据名称引用指定的 CustomLabel 对象比根据索引序号引用的对象更安全。

Add 方法可创建自定义标签。下列示例先添加一个名为“My Label”的自定义邮件标签,然后设置页面大小。

Set ML = _
    Application.MailingLabel.CustomLabels.Add(Name:="My Labels", _
    DotMatrix:=False)
ML.PageSize = wdCustomLabelA4