change MailMerge.DataSource

H

Hermann Schaffer

Ich want to change the datasource of a mailmerge documente from vb-code
(from an Access-application). Made the following coding:

Dim wrd As New Word.Application
wrd.Documents.Open "c:\scratch\My.doc"
wrd.ActiveDocument.MailMerge.OpenDataSource
Name:="c:\infar\MynewDS.mdb", _
LinkToSource:=True, Connection:="TABLE mytab"
wrd.ActiveDocument.Save
wrd.ActiveDocument.Close
wrd.Quit
Set wrd = Nothing

Problem: the DataSource-apllication (the access-db) stays open after the
quit-statement.
Qu1: is there a better way to change the dataSource? (or)
Qu2: how do I make sure the access-db will be closed?

- hermann -
 
H

Harold Kless[MSFT}

Hi Hermann,
It looks like you're using DDE to connect to the Data Source. Using ODBC or
OLEDB will connect to the Access database without opening the application.
I recorded this macro in Word 2000 to connect to Northwind using ODBC(
Some of this is not necessary).

wrd.ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\Program Files\Microsoft Office\Office10\Samples\Northwind.mdb",
_
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="",
Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"DSN=MS Access Database;DBQ=C:\Program Files\Microsoft
Office\Office10\Samples\Northwind.mdb;DriverId=25;FIL=MS
Access;MaxBufferSize=2048;PageTimeout=5;" _
, SQLStatement:="SELECT * FROM `Customers`", SQLStatement1:=""

Harold Kless, MCSD
Support Professional
Microsoft Technical Support for Business Applications
(e-mail address removed)

--


This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
 
H

Hermann Schaffer

opening the application ...<<

I could not yet try it, but I believe that 's it. Thank you very much. -
hermann -
 

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