Reply
 
Thread Tools Display Modes
  #1   Report Post  
Gerhard Kiessling
 
Posts: n/a
Default directly connecting the MailMerge object to MS SQL server

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 !
  #2   Report Post  
Peter Jamieson
 
Posts: n/a
Default

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

"Gerhard Kiessling" wrote in
message ...
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 !



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Border to an object moves the caption!?? bandy2000 Microsoft Word Help 1 March 27th 05 04:21 PM
Conditional inclusion of WordArt? Bill Watkins Mailmerge 13 February 1st 05 03:51 PM
MS Word Picture Object tj Microsoft Word Help 0 January 26th 05 03:09 AM
Inserted Object......advice please.... Dermot Microsoft Word Help 4 January 25th 05 09:13 PM
Included Property in Word 2003 MailMerge Alessio Mailmerge 1 December 23rd 04 11:26 AM


All times are GMT +1. The time now is 02:12 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"