S
susanmgarrett
When I hit the OK button on my form, the Contract # I've entered in an
unbound box in Access 2000 launched a MSWord 2000 mailmerge document.
Unfortunately, it launches BOTH the Word template and the final merged
document. Is there a Close argument I can put in either the Macro or
the Module that will close the Word document and leave open the merged
document and where would I place the code?
OR is there a code I can place in the Macro or module (or even some VB
Script) I can place that will launch ONLY the Merged document?
Macro and module codes are below.
Thank you for your help! It's most appreciated.
-----------------------------
Macro: conmha
1. Open Dialog
Action: Openform
FormName: Contract - Metal Hurlant Artist
Condition: Not IsLoaded("Contract - Metal Hurlant Artist")
Cancel Event
2. Close Dialog
Action: Close
Object Type: Form
Object Name: Contract - Metal Hurlant Artist
3. OKbutton
Action: SetValue
Action: RunCode
Function: MergeIt()
4. Cancelbutton
Action: Close
Object Type: Form
Object Name: Contract - Metal Hurlant Artist
Module: Mergewordmhaconart
Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject
("C:\humanoids\docs\contractmhart.doc", "Word.Document")
' Make Word visible. objWord.Application.Visible = True
' Set the mail merge data source as the Humanoids database.
objWord.MailMerge.OpenDataSource _
Name:="C:\humanoids\humanoids.mdb", _
LinkToSource:=True, _
Connection:="QUERY Query - ContractMHArt", _
SQLStatement:="SELECT * FROM [Query - ContractMHArt]"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function
unbound box in Access 2000 launched a MSWord 2000 mailmerge document.
Unfortunately, it launches BOTH the Word template and the final merged
document. Is there a Close argument I can put in either the Macro or
the Module that will close the Word document and leave open the merged
document and where would I place the code?
OR is there a code I can place in the Macro or module (or even some VB
Script) I can place that will launch ONLY the Merged document?
Macro and module codes are below.
Thank you for your help! It's most appreciated.
-----------------------------
Macro: conmha
1. Open Dialog
Action: Openform
FormName: Contract - Metal Hurlant Artist
Condition: Not IsLoaded("Contract - Metal Hurlant Artist")
Cancel Event
2. Close Dialog
Action: Close
Object Type: Form
Object Name: Contract - Metal Hurlant Artist
3. OKbutton
Action: SetValue
Action: RunCode
Function: MergeIt()
4. Cancelbutton
Action: Close
Object Type: Form
Object Name: Contract - Metal Hurlant Artist
Module: Mergewordmhaconart
Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject
("C:\humanoids\docs\contractmhart.doc", "Word.Document")
' Make Word visible. objWord.Application.Visible = True
' Set the mail merge data source as the Humanoids database.
objWord.MailMerge.OpenDataSource _
Name:="C:\humanoids\humanoids.mdb", _
LinkToSource:=True, _
Connection:="QUERY Query - ContractMHArt", _
SQLStatement:="SELECT * FROM [Query - ContractMHArt]"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function