Merge with Access - choose table

M

Mat

Hello all,

it would be nice if anyone could help me with the following:
I'm trying to set up a MainMergeDocument as connected to an Access table as data source. The problem I'm encountering is, that although I provide the table in the "connection"-property there always pops up a window asking for the table. I would like to avoid that pop-up. Here is the part of the code, where I open the datasource:
Documents("Umschläge.doc").MailMerge.OpenDataSource _
Name:=C:\Test.mdb, _
ReadOnly:=True, LinkToSource:=True, AddToRecentFiles:=False, _
Connection:="TABLE Contacts_Import"

I'm using Office 2003. Thanks a lot in advance for any help,
Mat
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?TWF0?=,

Quite likely, you're missing an necessary argument; SQLStatement, I should think, and
possibly SubType, as well.

I recommend you record a macro in Word while linking to this data source in the UI. Then
compare that code with what you have.
it would be nice if anyone could help me with the following:
I'm trying to set up a MainMergeDocument as connected to an Access table as data
source. The problem I'm encountering is, that although I provide the table in the
"connection"-property there always pops up a window asking for the table. I would like to
avoid that pop-up. Here is the part of the code, where I open the datasource:
Documents("Umschläge.doc").MailMerge.OpenDataSource _
Name:=C:\Test.mdb, _
ReadOnly:=True, LinkToSource:=True, AddToRecentFiles:=False, _
Connection:="TABLE Contacts_Import"

I'm using Office 2003.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in the
newsgroup and not by e-mail :)
 
C

Chris Joyce

The method you have been using dose not seem to work with word2003 , its
something to do with the way the auto connection string is being done , it
sometimes works.
you may find that a OLE connection type works better for you as it will work
with access2003 as well.

Chris

Sub ConnectToDataSrc()
'
' Connect to Databases is all different in Word 2003

ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:="C:\Test.mdb", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
_
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False,
_
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data
Source=C:\db1.mdb;Mode=Read;Extended Properties="""";Jet OLEDB:System
database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database
Password="""";Jet OLEDB:Engine Type=4;Jet OLEDB:Database Locking Mo" _
, SQLStatement:="SELECT * FROM `Contacts_Import`",
SQLStatement1:="", SubType:= _
wdMergeSubTypeAccess
End Sub
 
M

Mat

Hi Cindy,

thanks a lot for your help. I followed your method and it indeed works now. It was
obviously necessary to specify a subtype (I once tried an SQLStatement, but that didn't suffice). I also changed the database driver back to "TABLE Contacts_Import" and this also works (the recorded macro used the OLEDB connection).

So thanks again and have a nice day,
Mat
 
M

Mat

Hi Chris,

thanks a lot for your help. I followed the method Cindy pointed out and it indeed works now (it provides the same output you suggested). It was
obviously necessary to specify a subtype (I once tried an SQLStatement, but that didn't suffice). I also changed the database driver back to "TABLE Contacts_Import" and this also works (the recorded macro used the OLEDB connection). You write it works sometimes, so if it once doesn't work, I'll change it back to OLEDB.

So thanks again and have a nice day,
Mat
 
M

Michael Suttkus, II

This sounds like it might help solve a problem I have been having, but I
don't see where "subtype" is set, possibly because I'm using Office 2002.
Can anyone offer some help?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top