Hi all -
I've got a fairly simple automated system of Mail Merge from Access but I have one procedure that I would like to do but cannot figure out. I have the following Code:
[red]
Function DenialMerge()
Dim objWord As Word.Document
Set objWord = GetObject("C:\Denial.doc", "Word.Document"
' Show Word.
objWord.Application.Visible = True
' Set the data source of the merge to CCDB.
objWord.MailMerge.OpenDataSource _
Name:="S:\CCDBv3.0\Front_End\CCDB_v3.01.mdb", _
LinkToSource:=True, _
Connection:="QUERY qry_Denial_Form_Test", _
SQLStatement:="SELECT * FROM [qry_Denial_Form_Test]"
' Run it!
objWord.MailMerge.Execute
' Protect Denial Worsheet!
ActiveDocument.Protect Password:="password", NoReset:=
False, Type:= _wdAllowOnlyFormFields
End Function
[/red]
This works well and merges a document with basic demographics, and then locks that document so combo boxes on the document work for further work by the end user.
Problem is, when I run the code, the original document "Denial.doc" remains open after the merge has occurred along with the "Form Letter1" Document. Is there any way to close just the original "Denial.doc" without closing the Merge result "Form Letter1"?
Thanks!!
Andy
I've got a fairly simple automated system of Mail Merge from Access but I have one procedure that I would like to do but cannot figure out. I have the following Code:
[red]
Function DenialMerge()
Dim objWord As Word.Document
Set objWord = GetObject("C:\Denial.doc", "Word.Document"
' Show Word.
objWord.Application.Visible = True
' Set the data source of the merge to CCDB.
objWord.MailMerge.OpenDataSource _
Name:="S:\CCDBv3.0\Front_End\CCDB_v3.01.mdb", _
LinkToSource:=True, _
Connection:="QUERY qry_Denial_Form_Test", _
SQLStatement:="SELECT * FROM [qry_Denial_Form_Test]"
' Run it!
objWord.MailMerge.Execute
' Protect Denial Worsheet!
ActiveDocument.Protect Password:="password", NoReset:=
False, Type:= _wdAllowOnlyFormFields
End Function
[/red]
This works well and merges a document with basic demographics, and then locks that document so combo boxes on the document work for further work by the end user.
Problem is, when I run the code, the original document "Denial.doc" remains open after the merge has occurred along with the "Form Letter1" Document. Is there any way to close just the original "Denial.doc" without closing the Merge result "Form Letter1"?
Thanks!!
Andy