A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

directly connecting the MailMerge object to MS SQL server



 
 
Thread Tools Display Modes
  #1  
Old May 25th, 2005, 12:25 PM
Gerhard Kiessling
external usenet poster
 
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  
Old May 25th, 2005, 05:01 PM
Peter Jamieson
external usenet poster
 
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 !



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ADP 2000 deployment problems [email protected] General Discussion 25 June 16th, 2005 04:52 AM
what's the SQL for inserting OLE object into Access? Yaqian General Discussion 0 April 26th, 2005 04:15 AM
Automatically Connecting to SQL Server mac Running & Setting Up Queries 1 August 31st, 2004 02:28 PM
create table using access 2000 connecting to SQL Server 2000 Chris Running & Setting Up Queries 0 June 11th, 2004 06:41 PM
Mailmerge using SQL server Sydney Lotterby General Discussions 1 May 17th, 2004 04:16 PM


All times are GMT +1. The time now is 10:28 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.