Class MailingLabel (Word VBA)

The class MailingLabel represents a mailing label.

Set

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

Dim mll as MailingLabel
Set mll = Application.MailingLabel

MailingLabel class variables can be set using the Application.MailingLabel procedure.

CreateNewDocument

Creates a new label document using either the default label options or ones that you specify. Returns a Document object that represents the new document.

Syntax : expression.CreateNewDocument (Name, Address, AutoText, ExtractAddress, LaserTray, PrintEPostageLabel, Vertical)

addr = "Dave Edson" & vbCr & "123 Skye St." _ 
 & vbCr & "Our Town, WA 98004" 
Application.MailingLabel.CreateNewDocument _ 
 Name:="2160 mini", Address:=addr, ExtractAddress:=False

Arguments

The following arguments are optional

Name (String) - The mailing label name.

Address (String) - The text for the mailing label.

AutoText (String) - The name of the AutoText entry that includes the mailing label text.

ExtractAddress (String) - True to use the address text marked by the user-defined bookmark named "EnvelopeAddress" instead of using the Address argument.

LaserTray (WdPaperTray) - The laser printer tray. Can be one of the WdPaperTray constants.

Here you can find possible values for WdPaperTray.

PrintEPostageLabel (String) - True to print postage using an Internet e-postage vendor.

Vertical (Boolean) - True formats text vertically on the label. Used for Asian-language mailing labels.

CreateNewDocumentByID

Creates a new label document using either the default label options or ones that you specify. Returns a Document object that represents the new document.

Syntax : expression.CreateNewDocumentByID (LabelID, Address, AutoText, ExtractAddress, LaserTray, PrintEPostageLabel, Vertical)

Dim docCreateNewDocumentByID As Document
Set docCreateNewDocumentByID = Application.MailingLabel.CreateNewDocumentByID()

Arguments

The following arguments are optional

LabelID (String) - The mailing label identification.

Address (String) - The text for the mailing label.

AutoText (String) - The name of the AutoText entry that includes the mailing label text.

ExtractAddress (String) - True to use the address text marked by the user-defined bookmark named "EnvelopeAddress" instead of using the Address argument.

LaserTray (WdPaperTray) - The laser printer tray. Can be one of the WdPaperTray constants.

Here you can find possible values for WdPaperTray.

PrintEPostageLabel (String) - True to print postage using an Internet e-postage vendor.

Vertical (Boolean) - True formats text vertically on the label. Used for Asian-language mailing labels.

CustomLabels

Returns a CustomLabels collection that represents the available custom mailing labels.

For information about returning a single member of a collection, see Returning an object from a collection.

Dim strAddress As String 
Dim labelNew As CustomLabel 
 
strAddress = "Administration" & vbCr & "Mail Stop 22-16" 
 
Set labelNew = Application.MailingLabel _ 
 .CustomLabels.Add(Name:="AdminAddress", DotMatrix:= False) 
 
With labelNew 
 .Height = InchesToPoints(0.5) 
 .Width = InchesToPoints(1) 
 .HorizontalPitch = InchesToPoints(2.06) 
 .VerticalPitch = InchesToPoints(0.5) 
 .NumberAcross = 4 
 .NumberDown = 20 
 .PageSize = wdCustomLabelLetter 
 .SideMargin = InchesToPoints(0.28) 
 .TopMargin = InchesToPoints(0.5) 
End With 
 
Application.MailingLabel.CreateNewDocument _ 
 Name:="AdminAddress", Address:=strAddress

DefaultLabelName

Returns or sets the name for the default mailing label.

To find the string for the specified built-in label, select the label in the Label Options dialog box (Tools menu, Envelopes and Labels dialog box, Labels tab, Options button). Then click Details and view the Label name box, which contains the correct string to use for this property. To set a custom label as the default mailing label, use the label name that appears in the Details dialog box, or use the Name property with a CustomLabel object. Creating a new label document from a CustomLabel object automatically sets the DefaultLabelName property to the name of the CustomLabel object.

Msgbox Application.MailingLabel.DefaultLabelName

DefaultLaserTray

Returns or sets the default paper tray that contains sheets of mailing labels.

Possible Values are wdPrinterAutomaticSheetFeed - Automatic sheet feed, wdPrinterDefaultBin - Default bin, wdPrinterEnvelopeFeed - Envelope feed, wdPrinterFormSource - Form source, wdPrinterLargeCapacityBin - Large-capacity bin, wdPrinterLargeFormatBin - Large-format bin, wdPrinterLowerBin - Lower bin, wdPrinterManualEnvelopeFeed - Manual envelope feed, wdPrinterManualFeed - Manual feed, wdPrinterMiddleBin - Middle bin, wdPrinterOnlyBin - Printer's only bin, wdPrinterPaperCassette - Paper cassette, wdPrinterSmallFormatBin - Small-format bin, wdPrinterTractorFeed - Tractor feed, wdPrinterUpperBin - Upper bin.
If Application.MailingLabel.DefaultLaserTray = _ 
 wdPrinterManualEnvelopeFeed Then 
 StatusBar = "Printer set for feeding labels manually" 
Else 
 StatusBar = "Check printer paper tray setting" 
End If

LabelOptions

Displays the Label Options dialog box.

The LabelOptions method works only if the document is the main document of a mailing labels mail merge.

Sub LabelOps() 
 If ActiveDocument.MailMerge _ 
 .MainDocumentType = wdMailingLabels Then 
 Application.MailingLabel.LabelOptions 
 End If 
End Sub

Parent

Returns an object that represents the parent object of the specified MailingLabel object.

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

PrintOut

Prints a label or a page of labels with the same address.

Syntax : expression.PrintOut (Name, Address, ExtractAddress, LaserTray, SingleLabel, Row, Column, PrintEPostageLabel, Vertical)

addr = "Jane Doe" & vbCr & "123 Skye St." _ 
 & vbCr & "OurTown, WA 98107" 
Application.MailingLabel.PrintOut Name:="5664", Address:=addr

Arguments

The following arguments are optional

Name (String) - The mailing label name.

Address (String) - The text for the label address.

ExtractAddress (String) - True to use the text marked by the "EnvelopeAddress" bookmark (a user-defined bookmark) as the label text. If this argument is specified, Address and AutoText are ignored.

LaserTray (WdPaperTray) - The laser printer tray to be used. Can be any WdPaperTray constant.

Here you can find possible values for WdPaperTray.

SingleLabel (String) - True to print a single label; False to print an entire page of the same label.

Row (Row) - The label row for a single label. Not valid if SingleLabel is False.

Column (Column) - The label column for a single label. Not valid if SingleLabel is False.

PrintEPostageLabel (String) - True to print postage using an Internet e-postage vendor.

Vertical (Boolean) - True prints text vertically on the label. Used for Asian-language mailing labels.

PrintOutByID

Prints a label or a page of labels with the same address.

Syntax : expression.PrintOutByID (LabelID, Address, ExtractAddress, LaserTray, SingleLabel, Row, Column, PrintEPostageLabel, Vertical)

Application.MailingLabel.PrintOutByID

Arguments

The following arguments are optional

LabelID (String) - The mailing label identification.

Address (String) - The text for the label address.

ExtractAddress (String) - True to use the text marked by the "EnvelopeAddress" bookmark (a user-defined bookmark) as the label text. If this argument is specified, Address and AutoText are ignored.

LaserTray (WdPaperTray) - The laser printer tray to be used. Can be any WdPaperTray constant.

Here you can find possible values for WdPaperTray.

SingleLabel (String) - True to print a single label; False to print an entire page of the same label.

Row (Row) - The label row for a single label. Not valid if SingleLabel is False.

Column (Column) - The label column for a single label. Not valid if SingleLabel is False.

PrintEPostageLabel (String) - True to print postage using an Internet e-postage vendor.

Vertical (Boolean) - True prints text vertically on the label. Used for Asian-language mailing labels.

Vertical

True vertically orients text on Asian mailing labels.

Sub VerticalLabel() 
 If ActiveDocument.MailMerge.MainDocumentType = wdMailingLabels And 
 Application.Language = msoLanguageIDJapanese Then 
 Application.MailingLabel.Vertical = True 
 End If 
End Sub