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!

Create labels macro in Word 2010 1

Status
Not open for further replies.

Andrzejek

Programmer
Jan 10, 2006
8,569
US

I had a macro in Word 2003 that created some labels and I used the code in my VB 6 application.

Now we are moving to Word 2010, and my old macro does not work in Word 2010 any more. Fine, I will re-do it in Word 2010

In Word 2010, I have my Developer tab, I can record the macro:
Mailings – Start Mail Merge – Labels…

I can set Printer information, Label vendor (AVERY, US Letter), Product Number (5162 Easy Peel Address Labels) and then click OK. Labels are created, stop recording - life is good.

Now it’s the time to ‘steal’ code from new macro, use it in my VB application, and razzle-dazzle my boss.

All what I’ve got in my macro is one line:
Code:
Sub CreateLabels()[green]
' CreateLabels Macro[/green]
    ActiveDocument.MailMerge.MainDocumentType = wdMailingLabels
End Sub
Nothing about AVERY or label template number.
And if I run the new macro in Word 2010 - it doesn't work, doesn't create any lables, doesn't do anything. :-(

What am I doing wrong?


Have fun.

---- Andy
 


Andy,

Step into your procedure.

Highlight as shown...
Code:
Sub CreateLabels()
' CreateLabels Macro
    [highlight]ActiveDocument.MailMerge[/highlight].MainDocumentType = wdMailingLabels
End Sub
right-click in your highligh area and select Add Watch.

This exposes the properties & current values for that object. This info may help you proceed.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 

In Watches window I get Expression, value, type, and Context columns, and whole bunch of information in them, but that does not help me much :-(

In short, I just want to create a macro with the code I can use in VB 6 to create labels in Word 2010.

Have fun.

---- Andy
 



I recorded this while selecting a lable...
Code:
    Application.MailingLabel.DefaultPrintBarCode = False
    Application.MailingLabel.CreateNewDocumentByID LabelID:="1359804964", _
        Address:="", AutoText:="", LaserTray:=wdPrinterManualFeed, ExtractAddress _
        :=False, PrintEPostageLabel:=False, Vertical:=False

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 

Aha!

What I did originally was:
Mailings – Start Mail Merge – Labels...

And what you did was:
Mailings – (Create group) Labels - Options... (command button) - make some selections and hit OK, and then 'New Document' button.

And (I guess) all information for Label vendor and Product Number are in LabelID:="1359804964"

Now I will see if that will fly in VB 6 :)

Have fun.

---- Andy
 

Works like a dream.

Thanks Skip :)

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top