The code below is performing a mail merge in Word, but it is opening the document twice, first the original then a new, unsaved version. Is there anyway to just open the document once with the correct new data source? Or possibly close the original, keeping it unchanged, and giving the user a new doc they are free to manipulate and print from?
Dim objWord As Word.Document
Set objWord = GetObject("C:\StudentServices\Honors\Letter_JAH.doc"
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source
ActiveDocument.MailMerge.OpenDataSource Name:= _
CurrentProject.FullName, ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=wdOpenFormatAuto, _
Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=" & CurrentProject.FullName & ";Mode=Read;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDBatabase Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB" _
, SQLStatement:="SELECT * FROM [qryStudentMinor] WHERE tblMinor.ID= " & Me!txtID, SQLStatement1:="", _
SubType:=wdMergeSubTypeAccess
' Execute the mail merge.
objWord.MailMerge.Execute
Dim objWord As Word.Document
Set objWord = GetObject("C:\StudentServices\Honors\Letter_JAH.doc"
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source
ActiveDocument.MailMerge.OpenDataSource Name:= _
CurrentProject.FullName, ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=wdOpenFormatAuto, _
Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=" & CurrentProject.FullName & ";Mode=Read;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDBatabase Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB" _
, SQLStatement:="SELECT * FROM [qryStudentMinor] WHERE tblMinor.ID= " & Me!txtID, SQLStatement1:="", _
SubType:=wdMergeSubTypeAccess
' Execute the mail merge.
objWord.MailMerge.Execute