View Single Post
  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Printing Variable Label Quantities from a Merge

If you have a worksheet with the layout I described in Sheet1, the
following crude bit of Excel VBA code should delete any existing
"LabelRows" sheet, duplicate Sheet1, creating the right number of rows
in a new "LabelRows", which you should then be able to use as the merge
data source. The sheet will be at the beginning of the workbook should
you have to connect using DDE.

Probably best to work with copies of your data. This code doesn't do any
error checking to speak of, but should be OK if your label count doesn't
exceed the maximum number of rows

To do the whole thing from Word would require you either to integrate a
modified version of this macro, or something similar, into a Word VBA macro.

There are other ways that this problem could be approached, e.g.
a. If you have Access, its label generator may be worth investigation
b. there is another way to get Excel to return the right number of
rows without Excel VBA, but it's quite nasty

However, I think the above is straightforward and should certainly be a
good enough starting point if it's a one-off.

Peter Jamieson

http://tips.pjmsn.me.uk

On 20/02/2010 02:27, Wake Manor wrote:
It is an Excel file. And my plan was to use Word as the 'merger' ... I'm
looking at quantities from 1 - 250 - so the easier the better.

Thanks for the response.

"Peter Jamieson" wrote:

I can export the database


What type of database is it? (Excel workbook, access, some other
database?) You may be able to do something directly in there.

Otherwise, if
a. you can get an export like this

Product Quantity
A 1
B 5
C 7
..
..

and you know the maximum Qty (let's say it is 10), then
b. you can do this without having to resort to VBA:-

1. Create a directory (catalog) merge
Put the following fields in it
{ IF { MERGEFIELD QUANTITY } 0 "{ MERGEFIELD PRODUCT }
" }{ IF { MERGEFIELD QUANTITY } 1 "{ MERGEFIELD PRODUCT }
" }{ IF { MERGEFIELD QUANTITY } 2 "{ MERGEFIELD PRODUCT }
" }{ IF { MERGEFIELD QUANTITY } 3 "{ MERGEFIELD PRODUCT }
" }{ IF { MERGEFIELD QUANTITY } 4 "{ MERGEFIELD PRODUCT }
" }{ IF { MERGEFIELD QUANTITY } 5 "{ MERGEFIELD PRODUCT }
" }{ IF { MERGEFIELD QUANTITY } 6 "{ MERGEFIELD PRODUCT }
" }{ IF { MERGEFIELD QUANTITY } 7 "{ MERGEFIELD PRODUCT }
" }{ IF { MERGEFIELD QUANTITY } 8 "{ MERGEFIELD PRODUCT }
" }{ IF { MERGEFIELD QUANTITY } 9 "{ MERGEFIELD PRODUCT }
" }

NB, all the {} need to be the special field code braces you can enter
using ctrl-F9

2. Merge to a new document. You should have one column containing the
right number of rows for each PRODUCT. Manually insert the column header
PRODUCT, save and close the document and use it as the data source for
your label merge.

Peter Jamieson

http://tips.pjmsn.me.uk

On 19/02/2010 22:53, Wake Manor wrote:
Greetings;

I am trying to figure out how to print variable quantities of labels based
on a "quantity" field in a File. The purpose is to print out inventory
labels. I can export the database which will have, for example, the following
fields.

Product: A B C
Qty: 1 5 7

I can set up the basic merge (the Product line), but I want to be able to
tell Word to print out ONE label of "A", FIVE labels of "B" and SEVEN labels
of "C".

Help please!!!

Thanks

.