Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 29 of 29

Thread: Multiple-Record Word Mail Merge

  1. #21
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Cool. Learn how to use our VBA tags here, MD. So great to have you here!
    ~Anne Troy

  2. #22
    VBAX Newbie
    Joined
    Jun 2004
    Posts
    1
    Location
    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

  3. #23
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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.

  4. #24
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    I moved that recent post to here: http://www.vbaexpress.com/forum/showthread.php?t=2570
    ~Anne Troy

  5. #25
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    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

  6. #26
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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'

  7. #27
    VBAX Newbie
    Joined
    Apr 2010
    Posts
    1
    Location
    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

  8. #28
    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?

  9. #29
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    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]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •