A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

macro for word mailmerge



 
 
Thread Tools Display Modes
  #1  
Old February 3rd, 2010, 03:38 PM posted to microsoft.public.word.mailmerge.fields
Dirk
external usenet poster
 
Posts: 23
Default macro for word mailmerge

Hello
I want to seperate big mailmerge into 500 pages steps.
Can me somebody help to create this macro?
King regards in advanced.
Dirk
  #2  
Old February 3rd, 2010, 06:31 PM posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
external usenet poster
 
Posts: 4,550
Default macro for word mailmerge

In the simple case where you have a letter layout that uses one page and
always corresponds to a single record in the data source, you can use
something like

Sub batchmerge()
' number of records to process
' per batch
Const BatchSize As Long = 500
' a pathname for the output files
' We'll append the start record number
' (or you can merge to printer)
Const FileStem = "c:\a\batch_starting_"
Dim c As Long
Dim objDoc As Word.Document
c = 1
Set objDoc = ActiveDocument
With objDoc.MailMerge
.Destination = wdSendToNewDocument
While c = .DataSource.RecordCount
.DataSource.FirstRecord = c
.DataSource.LastRecord = c + BatchSize - 1
.Execute
ActiveDocument.SaveAs _
FileStem & CStr(c)
ActiveDocument.Close
c = c + BatchSize
Wend
End With
Set objDoc = Nothing
End Sub

If each letter always consumes (say) 5 records in the data source then
you could change
Const BatchSize = 500
to
Const BatchSize = 2500

However, if you have a more complicated letter where the number of
records each letter consumes (e.g. you are producing invoices) then it's
a different story because you do not actually know which record to start
with each time, and I don't believ it is particularly easy to find out.

Peter Jamieson

http://tips.pjmsn.me.uk

On 03/02/2010 15:38, Dirk wrote:
Hello
I want to seperate big mailmerge into 500 pages steps.
Can me somebody help to create this macro?
King regards in advanced.
Dirk

  #3  
Old February 3rd, 2010, 10:12 PM posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP
external usenet poster
 
Posts: 8,239
Default macro for word mailmerge

See the “Individual Merge Letters” item on fellow MVP Graham Mayor’s website
at:

http://www.gmayor.com/individual_merge_letters.htm


--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.

"Dirk" wrote in message
...
Hello
I want to seperate big mailmerge into 500 pages steps.
Can me somebody help to create this macro?
King regards in advanced.
Dirk


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:57 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.