Using the same mailmerge criteia for 2 different documents...

B

Bruce

Since Word mailmerge does not have the capability to do anything like a
"previous rec" after doing several nextrec when working with mailmerge, I am
trying to do the next best thing (and maybe even better!)

First, what I am trying to accomplish, and then you might even see something
easier that I can think of....

I have an excel spreadsheet that I use for my notary business. I create a
row for each clients transactions (there may be several entries for each
signing-this is what is causing the greif) that I witness for loan
signing(s) for. This worksheet has all the contact and billing info for
everybody for that signing (loan office, title co, escrow company etc) as
well as directions, all the dates that are important for the signing, the
fee I charge etc...

I created 1 document that has two pages that are created from the info in
the worksheet when I go to the clients home. One is "Signing Info"and the
other is "Invoice". Each of these sheets by themselves work fine. The
problem is that if I need to process several rows of info using NEXTREC in
the first sheet, then the second sheet will not be able to process the info
that was on the row I moved from. This is all understandable, no bugs or
anything.

What I _THINK_ I really need to do, is to split these into 2 separate docs
(created by 2 seperate DOTs) and then use them that way.

Now, here is what I am trying to figure out. How can I create both
documents, using the same info, as smoothly and automatically as possible? I
would ideally like to do this by running one macro.

Thanks,
Bruce
 
B

Bruce

This is a flat file. This is not a relationship issue. These are just
seperate entries of data when several are selected. ( I could use a
relationship, but then I would NOT be able to use word. )

These are not even using a pivot table. Just a selection of multiple rows of
data.

Thanks
Bruce
 
P

Peter Jamieson

OK, maybe something like

Sub DoubleMerge()

' Untested macro code...

Dim objMMMD1 As Word.Document
Dim objMMOD1 As Word.Document
Dim objMMMD2 As Word.Document
Dim objMMOD2 As Word.Document
Dim rngMMOD1 As Word.Range

' Open and merge document 1
Set objMMMD1 = Documents.Open(FileName:="mergedoc1.doc")

' Assume the merge data source is already set up
With objMMMD1.MailMerge
.Destination = wdSendToNewDocument
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute
End With

' The Activedocument is now the output document (unless there were errors
and a separate error output)

Set objMMOD1 = ActiveDocument
objMMMD1.Close SaveChanges:=False
Set objMMMD1 = Nothing

' Open and merge document 2

Set objMMMD2 = Documents.Open(FileName:="mergedoc2.doc")

' Assume the merge data source is already set up
With objMMMD2.MailMerge
.Destination = wdSendToNewDocument
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute
End With

' The Activedocument is now the output document (unless there were errors
and a separate error output)

Set objMMOD2 = ActiveDocument
objMMOD2.Content.Copy
Set rngMMOD1 = objMMOD1.Content
rngMMOD1.Collapse Direction:=wdCollapseEnd
rngMMOD1.Paste
objMMOD1.SaveAs FileName:="myname.doc"
objMMOD1.Close SaveChanges:=False
objMMOD2.Close SaveChanges:=False
Set objMMOD1 = Nothing
Set objMMOD2 = Nothing
Set rngMMOD1 = Nothing
End Sub

You may need to add/remove paragraphs around the inserted chunk (cf.

http://word.mvps.org/faqs/macrosvba/GetRngToEndOfInsertFile.htm

). You'll probably be better off putting any headers and footers in one of
the documents, and ensuring that your two documents don't use the same
paragraph/character style names in tow different ways.

Peter Jamieson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top