Class CustomLabels (Word VBA)

A collection of CustomLabel objects available in the Label Options dialog box. This collection includes custom labels of all printer types (dot-matrix, laser, and ink-jet printers). To use a CustomLabels class variable it first needs to be instantiated, for example


Dim cls as CustomLabels
Set cls = Application.MailingLabel.CustomLabels

For Each

Here is an example of processing the CustomLabels items in a collection.


Dim cll As CustomLabel
For Each cll In Application.MailingLabel.CustomLabels
	
Next cll

Add

Adds a custom mailing label to the CustomLabels collection. Returns a CustomLabel object that represents the custom mailing label.

Add (Name, DotMatrix)


Sub ReturnAddrLabel() 
 Dim ml As CustomLabel 
 Dim addr As String 
 
 Set ml = Application.MailingLabel.CustomLabels _ 
 .Add(Name:="Return Address", DotMatrix:=False) 
 ml.PageSize = wdCustomLabelLetter 
 addr = "Dave Edson" & vbCr & "123 Skye St." & vbCr _ 
 & "Our Town, WA 98004" 
 Application.MailingLabel.CreateNewDocument _ 
 Name:="Return Address", Address:=addr, ExtractAddress:=False 
End Sub

Arguments

The following argument is required

Name (String) - The name for the custom mailing labels.

Optional arguments

The following argument is optional

DotMatrix (Boolean) - True to have the mailing labels printed on a dot-matrix printer.

Count

Returns a Long that represents the number of items in the collection.


Dim lngCount As Long
lngCount = Application.MailingLabel.CustomLabels.Count

Item

Returns a CustomLabel object in a collection.

Item (Index)

Index: The individual object to be returned. Can be a Long indicating the ordinal position or a String representing the name of the individual object.


Dim cll As CustomLabel
Set cll = Application.MailingLabel.CustomLabels(Index:=1)