Cool. Learn how to use our VBA tags here, MD. So great to have you here!
Cool. Learn how to use our VBA tags here, MD. So great to have you here!
~Anne Troy
MD
Can you give me a little background on how this works?
I have a project that if I could modify your code and templates it would work.
If that is OK?
mld4165
Hi,
This has been a long term project with long periods of idleness and occasional spurts when I learn how to do things. Basically the Document is in four parts
1. Mergeall contains the Start of the document and leads into the list of NextRecord mergefields. It also contains all the macro coding
2. MergeHead contains the Start of the letter only
3. Mergefoot contains the letter footer, which may contain further merge records.
4. MergeData.rtf contains the data to be merged. One essential field is an ID for each Addressee or whatever.
The coding works by creating and index at the change of ID, going to a bookmark at the first NextRecord, counting down and inserting a MergeFoot, followed by a MergeHead, and repeating this process for each change in ID.
As a way forward, I am investigating analysing the basic mailmerge document which would contain one set of NextRecord records, and creating a set of Mhead, Mrec and Mfoot Autotext entries. These would be pasted into MergeAll as required, to form the basis for the new document.
One hiccup is the indexing of the records from the DataSource. While this works fine for 20 ? 30 records, it takes minutes for 250 or so records. A different mechanism is required here I think.
I moved that recent post to here: http://www.vbaexpress.com/forum/showthread.php?t=2570
~Anne Troy
md, can you you use
[VBA]
Do
With ActiveDocument.MailMerge.DataSource
.ActiveRecord = wdNextRecord
If .ActiveRecord = Num Then Goto ExitLoop
Num = .ActiveRecord
If Tmp <> ActiveDocument.MailMerge.DataSource.DataFields("ClientID").Value Then
i = i + 1
RS(i, 1) = i
RS(i, 2) = Num
Tmp = ActiveDocument.MailMerge.DataSource.DataFields("ClientID").Value
End If
End With
Loop
ExitLoop:
MsgBox msg
[VBA]
and what does this do ?
If .ActiveRecord = Num Then Goto ExitLoop
Num = .ActiveRecord
Hi,
I'm occupied elsewhere just now, but will try to have a look at it soon.
Regards
MD
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Hey there all. forum N00b here and was hoping someone can point me to where the files are that MD uploaded? Trying to help wife with this issue for her work. They have office 2k7 and hoping this will work for her.
Xanlythe
Second the post above. I'm new here, but I believe this would solve my problem.
Xanlythe, did you ever solve this issue via another method?
For a non-vba solution (in most cases), check out my Microsoft Word Catalogue/Directory Mailmerge Tutorial at:
http://lounge.windowssecrets.com/index.php?showtopic=731107
or
http://www.gmayor.com/Zips/Catalogue%20Mailmerge.zip
Do read the tutorial before trying to use the mailmerge document included with it.
Cheers
Paul Edstein
[Fmr MS MVP - Word]