Invoking Mail Merge from Excel
I invoke a mail merge from Excel where my calling Excel workbook
(TestMailMerge.xls) is also the data source for the Mail Merge. When I
close my Excel workbook, I get a message saying my Excel workbook is
available for editing; an instance appears to have been opened as
read-only by the Mail Merge.
My mail merge code is as follows:
ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\Documents and Settings\John Topley\My
Documents\TestMailMerge.xls", _
ConfirmConversions:=False, ReadOnly:=False,
LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="",
Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";Us er
ID=Admin;Data Source=C:\Documents and Settings\John Topley\My
Documents\TestMailMerge.xls;Mode=Read;Extended
Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet
OLEDB:Registry Path="""";Jet OLEDB:D" _
, SQLStatement:="SELECT * FROM `Year7$`", SQLStatement1:="",
SubType:= _
wdMergeSubTypeAccess
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
My environment is Windows XP and and Excel/Word 2002.
How can I close the Mail Merge instance of "TestMailMerge.xls" (Read
only) and remove the "error" message?
Thanks in advance for your help.
|