Word mailing labels - CreateNewDocument creates labels with wrong page size and margins

Word mailing labels - CreateNewDocument creates labels with wrong page size and margins

Post by danielki » Fri, 13 Apr 2007 12:02:54


Hello,

I am trying to automate Word (needs to be downward compatible to Word 2000,
so I'm using msword9.olb library) to do a mail merge to mailing labels.

I'm using VC++, but I've also tried this with VB, and the same problem
occurs.
I have directly put in the code found in article 258512, and the same
problem occurs... so this should be easy to reproduce.

The problem is this:

When I create the mailing labels using automation, it creates a gigantic
page of 11.22" x 12.05" size. The margins are all wrong, too.
I am trying to create a standard Avery 5160 label, and I pass in the code:

oNewDoc = oMLabel.CreateNewDocument( COleVariant( "5160"), vtOptional,
vtOptional, vtOptional, vtOptional);

And what I get in the end is a large page full of labels 4 across and 12
down. I tried to change the page size directly, but the labels is still 4
across and 12 down, which means it's not really Avery 5160.

I tried the equivalent in VB using Word 2007 type library, and I got the
same result.

My data source is a comma-delimited text file, but that shouldn't matter...
the merging is fine. It's just that the page size and the margins are all
wrong.

If you have any idea what is going on, and what I can do to fix it, I would
appreciate it very much.

Thank you.

--Daniel
 
 
 

Word mailing labels - CreateNewDocument creates labels with wrong page size and margins

Post by Cindy M » Sun, 15 Apr 2007 04:23:38

Hi Daniel,

I just did a test in Word 2003 (VBA) and got the right paper size.

In Word 2007, however, I do see what you describe. Further investigation (by
recording a macro) reveals that a new method has been introduced:
CreateNewDocumentById. This produces the expected result

Application.MailingLabel.CreateNewDocumentByID "1359804671"

I'm guessing the problem is that the number of labels (and companies providing
them) has grown so large that a string identification can no longer be relied
upon as being unique enough. A quick glance through the available labels
doesn't reveal any other with the number 5160 and the layout we're seeing, but
I'm betting there's one in there.

If you want something that can be used across all versions of Word, you may
need to resort to generating the table (a label page is, after all, just a
table), rather than using a "simple" command. Or supply a document (or
template) already set up as a label sheet and create a new document from that.


Cindy Meister
INTER-Solutions, Switzerland
http://www.yqcomputer.com/ (last update Jun 17 2005)
http://www.yqcomputer.com/

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)