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.
[quoted text clipped - 11 lines]
> 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 :-)