D
Dazed And Confused
I am new (I know next to nothing) to mail merges, but want to merge
data in an Access select query with a word document. After much
searching and copying and pasting and generally messing around, I
finally came up with the following code which I run from the Access VB
Editor:
Function MergeLeaveSlips()
Dim objWord As Word.Document
Set objWord = GetObject("C:\Work\LeaveSlipsMerge_Test.doc",
"Word.Document")
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource _
Name:="C:\Work\LeaveSlipsMergeDB_Test.mdb", _
LinkToSource:=True, _
Connection:="Query Leave_Slips_Test", _
SQLStatement:="SELECT * FROM [Leave_Slips_Test]"
objWord.MailMerge.Execute
End Function
What happens is I get a message telling me that "This document will
run the following command: Select * From Leave_Slips_Test . . ."
If I click okay, it then brings up a screen to select the data source.
I need to find a way that the "This document . . ." message won't show
up and it won't ask the user for a data source. Bearing in mind that
I barely understand what this code even does, can anyone help before I
lose what little hair I have?
Thanks very much!!!
SJ
data in an Access select query with a word document. After much
searching and copying and pasting and generally messing around, I
finally came up with the following code which I run from the Access VB
Editor:
Function MergeLeaveSlips()
Dim objWord As Word.Document
Set objWord = GetObject("C:\Work\LeaveSlipsMerge_Test.doc",
"Word.Document")
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource _
Name:="C:\Work\LeaveSlipsMergeDB_Test.mdb", _
LinkToSource:=True, _
Connection:="Query Leave_Slips_Test", _
SQLStatement:="SELECT * FROM [Leave_Slips_Test]"
objWord.MailMerge.Execute
End Function
What happens is I get a message telling me that "This document will
run the following command: Select * From Leave_Slips_Test . . ."
If I click okay, it then brings up a screen to select the data source.
I need to find a way that the "This document . . ." message won't show
up and it won't ask the user for a data source. Bearing in mind that
I barely understand what this code even does, can anyone help before I
lose what little hair I have?
Thanks very much!!!
SJ