Could anyone suggest a reason why this code would not close the word document but leave it open in the background. It works on all versions up to 2013,
Code:
With o_App
Set o_Doc = .Documents.Add(szWordPath & szDocumentFilename, False)
If CInt(o_App.Version) < 10 Then
'Word 97 and 2000
o_Doc.Mailmerge.OpenDataSource Name:=GetDBFilenamep(), _
ReadOnly:=False, Connection:=szConnection ', _
OpenExclusive:=False, SubType:=wdMergeSubTypeWord2000
Else
'Word xp and higher
szQueryName = Replace(szConnection, "QUERY ", "")
szTempTextFilePath = GetDBPath() & "/" & szQueryName & ".txt"
DoCmd.TransferText acExportDelim, , szQueryName, szTempTextFilePath, True
o_Doc.Mailmerge.OpenDataSource _
Name:=szTempTextFilePath, _
ReadOnly:=True
End If
o_Doc.Mailmerge.Destination = 0
.Visible = True
.Activate
.WindowState = 1
o_Doc.Mailmerge.Execute Pause:=False
End With
o_Doc.Close 0