Class CustomLabel (Word VBA)

The class CustomLabel represents a custom mailing label. The CustomLabel object is a member of the CustomLabels collection. The CustomLabels collection contains all the custom mailing labels listed in the Label Options dialog box.

The main procedures of class CustomLabel are Delete and CustomLabels.Add


To use a CustomLabel class variable it first needs to be instantiated, for example

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

The following procedures can be used to set variables of type CustomLabel: CustomLabels.Add, CustomLabels.Item and MailingLabel.CustomLabels

For Each

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

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


The following procedures in this class have been grouped together and are described on a separate theme page

Number with its procedures NumberAcross and NumberDown


These are the main methods of the CustomLabel class

Delete - Deletes the specified custom label.


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

Dim strName As String: strName =  
Dim cll As CustomLabel
Set cll = Application.MailingLabel.CustomLabels.Add(Name:=strName)


DotMatrix true if the printer type for the specified custom label is dot matrix. False if the printer type is either laser or ink jet.

Dim booDotMatrix As Boolean
booDotMatrix = Application.MailingLabel.CustomLabels(1).DotMatrix

Height returns or sets the height of a specified custom mailing label, in points.

Application.MailingLabel.CustomLabels(1).Height =

HorizontalPitch returns or sets the horizontal distance (in points) between the left edge of one custom mailing label and the left edge of the next mailing label.

Application.MailingLabel.CustomLabels(1).HorizontalPitch =

Index returns a Long that represents the position of an item in a collection.

Dim lngIndex As Long
lngIndex = Application.MailingLabel.CustomLabels(1).Index

Name returns or sets the name of the specified object.

Application.MailingLabel.CustomLabels(1).Name =

PageSize returns or sets the page size for the specified custom mailing label.

Application.MailingLabel.CustomLabels(1).PageSize = wdCustomLabelA4

Parent returns an object that represents the parent object of the specified CustomLabel object.

Dim objParent As Object
Set objParent = Application.MailingLabel.CustomLabels(1).Parent

SideMargin returns or sets the side margin widths (in points) for the specified custom mailing label.

Application.MailingLabel.CustomLabels(1).SideMargin =

TopMargin returns or sets the distance (in points) between the top edge of the page and the top boundary of the body text.

Application.MailingLabel.CustomLabels(1).TopMargin =

Valid true if the various properties (for example, Height, Width, and NumberDown) for the specified custom label work together to produce a valid mailing label.

Dim booValid As Boolean
booValid = Application.MailingLabel.CustomLabels(1).Valid

VerticalPitch returns or sets the vertical distance between the top of one mailing label and the top of the next mailing label.

Application.MailingLabel.CustomLabels(1).VerticalPitch =

Width returns or sets the width of a custom mailing label, in points.

Application.MailingLabel.CustomLabels(1).Width =

CustomLabels.Count returns a Long that represents the number of items in the collection.

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

CustomLabels.Parent returns an object that represents the parent object of the specified CustomLabels object.

Dim objParent As Object
Set objParent = Application.MailingLabel.CustomLabels.Parent