View Single Post
  #4   Report Post  
Cindy M -WordMVP-
 
Posts: n/a
Default

Hi Alessio

Ah, OK, your connection is using OLE DB. Usually, when you see the
message you report, with an OLE DB connection, it usually one of the
other arguments is missing, such as an SQLStatement or a TableName. Why
this would be happening in some instances, and not others, is difficult
to determine without knowing more about how the documents were created,
and what criteria decide which parameters + values are being passed to
the OpenDatasource method.

Given that you can resolve the problem by copying/pasting to a new Excel
Workbook, I'd be inclined to guess that there may be some file damage in
the workbooks you're being sent that's preventing the OLE DB connection
from "seeing" the worksheet.

In your situation, I'd probably

1. test what happens if you try to manually make the connection, in the
Word UI

2. If it works, record that in a macro and compare the code

3. If it doesn't work, see if connecting using ODBC works. If it does,
record that in a macro and adjust your code to use an ODBC connection
method instead of OLE DB. In my experience ODBC is the most reliable,
across all Office versions, with an Access or Excel data source.

thank you for your answer. I take it you mean that my code (which is a
C++ application working with Word2003) should use explicitly DDE.
Actually, the application currently works with the following Connection
string (the 12th argument passed to the OpenDataSource method):

"Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=" +
sDataSourcePath + ";Mode=Read;Extended
Properties=\"HDR=YES;IMEX=1;\";Jet OLEDB:Engine Type=35"

while, if I understand what you said, I should replace the use of Jet
OLEDB with the use of DDE. Is it correct?
But I have two questions:
1) why does the current application works with most of the mailmerge
documents submitted to it?
2) why doesn't it work with only some othe documents?


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)