Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word - MailingLabels

Status
Not open for further replies.

pfildes

Programmer
Jun 17, 2004
54
GB
I had a Word97 document with the following source for printing bar code labels. It works fine with Office97 but fails with Office2003 displaying the message;
[red]
Run-time error '5843':
One of the values passed to this method or property is out of range.
[/red]

Code:
Application.MailingLabel.DefaultPrintBarCode = False
Application.MailingLabel.CreateNewDocument Name:="A4 8 x 3 per sheet", Address:="", _
        AutoText:="ToolsCreateLabels2"
 
Methinks
AutoText:="ToolsCreateLabels2"
is missing in your new version.

Check to see if you have such an Autotext entry. (Tools, AutoCorrect options..., AutoText tab)

Member- AAAA Association Against Acronym Abusers
 
I actually resolved my problem by creating a CustomLabel for the MailingLabel (see code) :)
Code:
    Set myMailingLabel = Application.MailingLabel
    Set myCustomLabel = myMailingLabel.CustomLabels.Add(Name:="MyBarcodeLabel", DotMatrix:=False)
    
    With myCustomLabel
        .PageSize = wdCustomLabelA4
        .NumberAcross = 3
        .NumberDown = 8
        .Height = MillimetersToPoints(36#) 'InchesToPoints(1.43)
        .HorizontalPitch = MillimetersToPoints(70#) 'InchesToPoints(2.75)
        .SideMargin = MillimetersToPoints(0#) 'InchesToPoints(0#)
        .TopMargin = MillimetersToPoints(4#) 'InchesToPoints(0.15)
        .VerticalPitch = MillimetersToPoints(36#) 'InchesToPoints(1.43)
        .Width = MillimetersToPoints(70#) 'InchesToPoints(2.75)
    End With

    'If the custom label is valid then create a new document using the
    'custom label.
    If (myMailingLabel.CustomLabels("MyBarcodeLabel").Valid = True) Then
        myMailingLabel.DefaultPrintBarCode = False
        myMailingLabel.CreateNewDocument Name:="MyBarcodeLabel", Address:="", _
                                         AutoText:="ToolsCreateLabels2"
        'Application.MailingLabel.DefaultPrintBarCode = False
        'Application.MailingLabel.CreateNewDocument Name:="A4 8 x 3 per sheet", Address:="", _
        '                                           AutoText:="ToolsCreateLabels2"
    Else
        MsgBox "The " & Chr(34) & "MyBarcodeLabel" & Chr(34) & " custom label is not available, or" & Chr(13) & _
               "the settings are not valid"
        Set myCustomLabel = Nothing
        Set myMailingLabel = Nothing
        Exit Sub
    End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top