PDA

View Full Version : Solved: Mail Merge layout setting



ronanoc_11
07-21-2005, 01:01 PM
Hi,

I hope I'm using this forum correctly.
My questions are: Am I able to set the mail merge layout of a document to Avery A4/A5 using code. And if so, does anyone know the code.
I did this manually, recorded it as a macro, then stepped into the code hoping this particular statement would display. It didn't.
The background to this is that I have an asp page that generates a mail merge document populated with data from sql server. The only problem is that it displays 10 rows per page. I'm after seven which is the Avery A4/A5 setting. By getting the code in word, I might be able to adapt it to the vb script in the asp page. Maybe not but that's what I was hoping.
Any help would be greatly appreciated. Thank-you

MOS MASTER
07-21-2005, 03:55 PM
Hi and welcome to VBAX! :hi:

Do you mean by: "Avery A4/A5 " the label format?

Or do you change it by page setup?

In other words can you describe how you set up the avery setting by hand? Usualy everything can be coded so if I know the steps I'll have a go at it.

HTH, :whistle:

ronanoc_11
07-21-2005, 04:17 PM
Hi MOS MASTER,

Thanks for the reply and welcome.
I actually found the solution.
This is the course I followed when I did it manually and recorded by macro.
I selected
Tools - mail merge
Create - Mailing labels
I pressed the Active Document button
I selected
Get Data - Use Address book (irrelevant for my purposes)
I selected my address book and pressed the Set up Main Document button

The Label options dialog appears - this is the important bit. BY trail and error I found the the page layout that suited me is got by selecting
Label Products - Avery A4 and A5 sizes
Product Number - C2160-Sticker

I wanted to see what the code was behind this last action so that I could adapt it to my asp page. I got my asp code from http://support.microsoft.com/?kbid=258512

it had the following line of code

oApp.MailingLabel.CreateNewDocument Name:="5160", Address:="", _
AutoText:="MyLabelLayout", LaserTray:=wdPrinterManualFeed

I replaced 5160 with C2160 and it worked. Seems very simple after the event.

Thanks very much for the reply
roc

MOS MASTER
07-21-2005, 04:22 PM
Hi Roc, :yes

Glad you found your sollution!

Till the next encounter! :thumb

j19_2002
09-16-2008, 03:19 PM
glad for ya! another problem solved, i luv these forums!!