View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Mail Merge connection is lost

There are some problems in this area (although I thought there was a
knowledgebase article covering it, I can't find it right now).

As far as I know, the only thing you can really do (other than stuff like
"change your data source to be something else") is to use VBA code in an
"Autoopen" macro to open the data source with the appropriate query to
filter the data. That is only really feasible if
a. you always save the mail merge main document disconnected from its data
source
b. you or your users are not changing the filter criteria all the time
c. you are not selecting/deselecting individual records in the Recipients
dialog box.

To do it, you need
d. to determine the query your mail merge main document is using. You
should be able to determine that by opening the mail merge main document,
setting up the mail merge data source (again :-( ) and filter/sort criteria,
then starting the VBA Editor, opening the Immediate window, and typing

print activedocument.mailmerge.datasource.querystring

you should see a response such as "SELECT * FROM tablename WHERE conditions"

e. Create an autoopen macro that does

Sub AutoOpen()

' Substitute the type of mail merge you need
With ActiveDocument.MailMerge
' Substitute the type of mail merge you need
.MainDocumentType = wdFormLetters
' Substitute the destination you need
.Destination = wdSendToNewDocument
' substitute the Excel file you need, and the query you got from step (d)
.OpenDataSource _
Name:="the full path name of your Excel file", _
.SQLStatement:="the SELECT statement you got from step (d)"
End With

End Sub

For further info. on VBA etc. see e.g.

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

especially

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

and

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

It is also possible that Office 2002 SP3 fixes this problem, although I do
not think it does.

Peter Jamieson


"vicchic01" wrote in message
...
I am using Word 2002 and have created a mail merged word document.

If the mail merge is not restricted (all records in the data source are
connected with the word document) then the main merge document keeps its
connection with the data source (an excel 2002 spreadsheet) every time you
open it. If, however, you apply a filter (see step 3 of the mail merge
wizard process) and save the word document, then you must find the data
source every time you open the document again. Very frustrating !

I have searched the internet for a possible solution but have not found
anything? Any ideas?