Link to home
Start Free TrialLog in
Avatar of swanzey
swanzey

asked on

Mailmerge condition to next label

I have a mailmerge between word 2010 and an excel spreadsheet. Each record in the spreadsheet includes a quantity field in which I wish to print that particular label the specified number of times before going to the next label.

What do I have to do to print a label based on the quantity of labels before going to the next label? A specific example is appreciated.
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

I think that the easiest way would be to create a new sheet that has a row for each instance of each required label.
Avatar of swanzey
swanzey

ASKER

But isn't there a way to use nextif while decrementing the qty counter or something?

Thx
I have considered running the MailMerge under VBA control, but I can see snags in the case of labels. It might be possible using arithmetic in Word Fields.

I'll look again at each approach, but, as I said, creating a new sheet especially for the merge would seem to be the simplest way.
I've tried VBA. I works in producing the correct number of labels, but each one is the first on a new page of labels.
Sub MultiLabels(wdDoc As Word.Document)
    Dim r As Integer
    Dim LabelCount As Integer
    With wdDoc.MailMerge
        .MainDocumentType = wdMailingLabels
        .Destination = wdSendToNewDocument
        For r = 1 To .DataSource.RecordCount
            .DataSource.LastRecord = r
            .DataSource.FirstRecord = r
            LabelCount = .DataSource.DataFields("Count").Value
            Do While LabelCount > 0
                .Execute
                LabelCount = LabelCount - 1
            Loop
            .Execute
        Next r
    End With
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial