Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mail Merge Opens the document twice

Status
Not open for further replies.

charle525

MIS
Jul 18, 2003
23
0
0
US
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 OLEDB:Database 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top