473,325 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Automating Word Mail Merge - confirm data source problems

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
1 12208
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Julia Baresch | last post by:
Everyone, I posted the message below back in February and didn't get any information. I also wasn't able to find any documentation in MS Help, web site, or other groups. I'm posting now with...
5
by: Jerry Hull | last post by:
I'm working with a database developed by an untrained person over several years - and on a network that has recently been upgraded with a new server installed and MS office upgraded from 2K (I...
1
by: John Davy | last post by:
I am trying to set up a mail merge by automation using a text file as the data source but I keep getting the message "Requested object is not available" and the debugger stops on the...
10
by: John | last post by:
Hi I am trying to do a word mailmerge form within my vb.net app. My problem is how to do a query on one of my tables and use the result as the mail merge datasource. Any help would be...
2
by: Colin Halliday | last post by:
I have a Word 2003 mail merge main document (form letter) that is linked to another Word document data source for the mail merge. If I open this doc using the Word GUI, it first asks me to...
0
by: Darragh | last post by:
I'm encountering some serious problems trying to set Access 2000 querys (parameters and views) as data sources for my mail merge documents (Word 2003). After spending hours scouring the web for...
8
by: Ron B | last post by:
Help!!! What am I doing wrong? I am working with Office 2003 and am trying to create a command button on an Access form that will create a mail merge in Word from an Access table. I want to...
3
by: Bishman | last post by:
Hi, I have some issues with the code below. These are: ONE: In code I open an existing document and 'attach' the Mail Merge data source, but the data is not poulating the merge fields...
1
by: TommyGunn | last post by:
Hi everyone, Is there anyway to automatically put Access data into Mail Merge in an existing Word doc with content? I have bits and pieces of this done, but I can't seem to put it all together....
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.