I'm trying to use the Mergit() function from the MS Knowledge base article
to merge data from a query or table in my Access 2000 mdb into an existing
word merge document. Every time it runs it brings up the dialog "Confirm
Data Source", and asks if I want to use OLE, DDE, or ODBC. If I say ODBC,
it then asks me for the table name. If I do all that, the merge works
correctly, but I don't want users to have to do all that. I thought the
Mergeit function was supposed to supply all the necessary info on the data
source. I've searched a bunch on Google, and tried both settings of the
"Confirm Conversion On Open" checkbox in Word's options, but nothing helps.
Has anyone had success making this function work smoothly, or does anyone
have a different example that works?
thanks
-John
here's the code I'm using:
Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("C:\MyMerge.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source.
objWord.MailMerge.OpenDataSource _
Name:="C:\ofrf.mdb", _
LinkToSource:=True, _
Connection:="TABLE People", _
SQLStatement:="SELECT firstname, lastname FROM People"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function