By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,810 Members | 783 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,810 IT Pros & Developers. It's quick & easy.

Automating Word Mail Merge - confirm data source problems

P: n/a
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
Apr 23 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
OK, I figured it out. (Embarrasingly soon after the original post).The
problem was that Word 2002 uses OLE via something called OSDO (Office Data
Source Object) as the default connection type, instead of DDE which is used
by Word 97 and 2000. You can get around this by forcing Word 2002 to act
like Word 2000, by adding the following parameter to the openDataSource
method:

subtype:=wdMergeSubTypeWord2000

this info came from the following KB article:
http://support.microsoft.com/kb/289830/EN-US/

"John Welch" <john(remove)welch@cal(remove)central.com> wrote in message
news:e2********@enews4.newsguy.com...
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

Apr 23 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.