Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / May 2005

Tip: Looking for answers? Try searching our database.

directly connecting the MailMerge object to MS SQL server

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gerhard Kiessling - 25 May 2005 12:25 GMT
Hello @ll,

I'm trying to directly connect an MS Word MailMerge object to an SQL server
table
(Word XP German)

code e,g,
   ActiveDocument.MailMerge.OpenDataSource _
       Name:="", _
       Connection:="Provider=SQLOLEDB.1;Persist Security
Info=False;UserID=[UID];Initial Catalog=[database];Data Source=[server]", _
       SQLStatement:="SELECT * FROM ""table"""

When executing OpenDataSource Word always opens a file dialog "select data
source"
       
If I select a (former created for test purposes) ODC-file, the command is
passed.
If I cancel the dialog, the code runs against runtime error 4198 'command
failed'.

But I don't like to have the user select the data source, I would like to
connect per only (so the user does not know - and is not interested - where
the data are from)

Can anyone help ?
How must the parameter 'Name' be filled, so that there is no file data
source required ?

Appendix : connection string and sql command are prooved and are working
properly, so this is not the reason ...

Thanks for any help !
Peter Jamieson - 25 May 2005 17:01 GMT
The only way to avoid using a file name is to use an ODBC User or System
DSN. In that case you need to use an ODBC connection string rather than an
OLEDB one, and specify an additional parameter, i.e.

Subtype:=wdMergeSubTypeWord2000

One thing you can do is to use an empty .odc file (e.g. create an empty file
in Notepad and save it as "leer.odc") - as long as you pass everything else
you need in the Connection and SQLStatement parameters you should be OK.

Peter Jamieson

> Hello @ll,
>
[quoted text clipped - 32 lines]
>
> Thanks for any help !
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.