View Single Post
  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Connecting to Access

Peter, I already have VBA working in Access to run the merge. My
problem is in setting up a document to point at the Access table as the
source of the mail merge data. I have tried copying one of the documents
that does point at the same table in the hope that it would still do so,
but the copy points at an Excel spreadsheet of the same name.

Do I need to rename my workgroup information file, Secured.mdw, to
System.mdw? I suspect that the New Data Source process will only look
at a file of that name.


Since Access is definitely open when you merge, your options a
a. connect using DDE. DDE communicates with Access, which already has
the DB open, so Word does not need to know anything about workgroup
security in that case. But I do not think it is possible to force Word
2007 to use DDE with Access programmatically
b. connect via ODBC/OLE DB, supplying the workgroup name, login and
password, as I have suggested. OLE DB is probably better. I do not
believe that the name of the workgroup DB makes any difference - you
still have to supply it. However, I have not verified that recently.
c. (I would have to re-check this) ensure that the table/query you
wanted to use was /not secured/. In that case you probably do not need
to provide the workgroup DB details, and Word will /probably/ try to log
in as Admin.

Peter Jamieson

http://tips.pjmsn.me.uk

On 03/03/2010 08:02, Murray Muspratt-Rouse wrote:
Peter Jamieson;459888 Wrote:
You need to do one of the following:
a. specify the workgroup database name, and the appropriate user name

and password, in a connection string in VBA, e.g.

ActiveDocument.MailMerge.OPenDataSource _
Name:="the pathname of your DB", _
Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;Password=thepass word;"& _
"User ID=theuserID;Data Source=the pathname of your DB;"& _
"Jet OLEDB:System Database=the pathname of your workgroup DB;", _
SQLStatement:="SELECT * FROM [your table]

b. (you can probably do it by putting the same information in a .odc
file)

Notice that in either case, the username/password info will probably
end
up being rather easy to discover (in plain text in the .odc, and inside

the Word file in case (a))

Peter Jamieson

http://tips.pjmsn.me.uk

Peter, I already have VBA working in Access to run the merge. My
problem is in setting up a document to point at the Access table as the
source of the mail merge data. I have tried copying one of the documents
that does point at the same table in the hope that it would still do so,
but the copy points at an Excel spreadsheet of the same name.

Do I need to rename my workgroup information file, Secured.mdw, to
System.mdw? I suspect that the New Data Source process will only look
at a file of that name.