Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
mar.s.i. mar.s.i. is offline
external usenet poster
 
Posts: 1
Default mailmerging number of copies

i have a word document and excel file as datasource for mailmerging.
what i want to accomplish is to mailmerge the document
printing (n times) based on datasource column per record.


is it possible?

thanks a lot
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default mailmerging number of copies

As long as each printed document corresponds to a single record in your
Excel data source, you could try the following macro. I've tested this macro
without the "per copy" loop, but not with that extra loop, so there could be
errors in the

Sub PrintXDocsPerSourceRec()
Dim intCopies As Integer
Dim intCopy As Integer
Dim intSourceRecord As Integer
Dim objMerge As Word.MailMerge
'Dim strOutputDocumentName As String
Dim TerminateMerge As Boolean

' Need to set up this object as the ActiveDocument changes when the
' merge is performed.

Set objMerge = ActiveDocument.MailMerge
With objMerge

' If no data source has been defined, do it here using OpenDataSource.
' But if it is already defined in the document, you should not need
' to define it here.

' .OpenDataSource _
' Name:="whatever"

intSourceRecord = 1
TerminateMerge = False

Do Until TerminateMerge
.DataSource.ActiveRecord = intSourceRecord

' Get the number of copies to print.
' Let's assume the number is in a column called "CopyCount"
' make sure you use exactly the same field name here
' - upper/lower case is significant

intCopies = .DataSource.DataFields("CopyCount").Value

' if we have gone past the end (and possibly, if there are no records)
' then the Activerecord will not be what we have just tried to set it to

If .DataSource.ActiveRecord intSourceRecord Then
TerminateMerge = True
' the record exists
Else
For intCopy = 1 To intCopies
.DataSource.FirstRecord = intSourceRecord
.DataSource.LastRecord = intSourceRecord
.Destination = wdSendToPrinter
.Execute
Next

intSourceRecord = intSourceRecord + 1
End If
Loop
End With
End Sub

If you haven't used Word VBA Macros before, see


http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm




--
Peter Jamieson
http://tips.pjmsn.me.uk

"mar.s.i." wrote in message
...
i have a word document and excel file as datasource for mailmerging.
what i want to accomplish is to mailmerge the document
printing (n times) based on datasource column per record.


is it possible?

thanks a lot


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I number consecutively many copies of the same form? Rennie Microsoft Word Help 1 June 28th 06 09:46 PM
How do I number 100 copies of a flyer I created from 1 to 100? Frantz Bartoli Page Layout 3 June 25th 06 07:39 AM
How to increment a number on one page for several copies of the sa store5064 Microsoft Word Help 2 May 29th 05 03:20 AM
Number * of 150 copies in a label Martin ©¿©¬ @mandeREMOVETHIS.plus.com Tables 4 December 26th 04 03:40 PM
number of copies defaulted at 2 JasonC Microsoft Word Help 1 December 16th 04 08:55 PM


All times are GMT +1. The time now is 09:42 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"