| View previous topic :: View next topic |
| Author |
Message |
Didier Guest
|
Posted: Fri Dec 15, 2006 4:21 pm Post subject: pb with using excel com Object |
|
|
Hello
I 'm using c++Builder (update pack 1) on my pc (Windoxs xp home) and
excel97
I've written my project which use com Object excel with variant etc .
No problem that's run fine
I've made an evolution ogf my program (adding one thread) and now i get the
next information windows when i try to conne ct to excel applicaton
_ASSERTE:
IsBound() failed-d:\bcb\emuvcl\ utilcls.h/4039
Pres Y to terminate N to continue C TO debug
when I press Yes i get the next message
Isbound() failed d:\bcb\....
Has anybody encounter this problem
One remark :
I don't think i 've corrupt files because my first project runs on the same
pc with the same method to access Excel Application |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Dec 15, 2006 4:33 pm Post subject: Re: pb with using excel com Object |
|
|
"Didier" <dbodinier (AT) wanadoo (DOT) fr> wrote in message
news:458276cd$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I've made an evolution ogf my program (adding one thread) and now i get
the
next information windows when i try to conne ct to excel applicaton
_ASSERTE:
IsBound() failed-d:\bcb\emuvcl\ utilcls.h/4039
|
Are you trying to connec to Excel inside the thread? If so, then you call
CoInitialize() first?
Gambit |
|
| Back to top |
|
 |
Didier Guest
|
Posted: Fri Dec 15, 2006 7:15 pm Post subject: Re: pb with using excel com Object |
|
|
Well I've just written a third project with just a form and a button whose i
use the clickmethod to access to excel (in this method i use the same code
as i use in the fisrst project ) ; So I have the same error IsBound() ....
: so i think in my last project (the third) i have a different configuration
that i had in my first project ; I 'm looking for all options or other
configuration case but at htis time i don't have found
Here is my code which run in my first project !!!! and fails in my third
project
int numero_ligne;
Variant vMSExcel,vXLWorkbook,vXLWorkbooks;
Variant vFileName;
Variant vWorksheet,vSheetName;
Variant vValue,vRange,vCell;
Variant vSaveChanges;
AnsiString aValue[5];
AnsiString sTemp,sLigne;
char Valeur[3];
unsigned short i,index;
try
{
vMSExcel = Variant::GetActiveObject("Excel.Application");
}
catch(...)
{
vMSExcel = Variant::CreateObject("Excel.Application");
}
vMSExcel.OlePropertySet("Visible",false);
vFileName="C:\\Program files\\Aeroproduct\\Statistiques.xls";
vXLWorkbooks =vMSExcel.OlePropertyGet("Workbooks");
vSheetName="Feuil1";
vWorksheet=vXLWorkbook.OlePropertyGet("Worksheets",vSheetName);
vRange=StringToOleStr("A1");
vCell=vWorksheet.OlePropertyGet("Range",vRange);
sTemp=vCell.OlePropertyGet("Value");
vSaveChanges = true;
vXLWorkbook.OleFunction("Close",vSaveChanges);
vMSExcel.OleFunction("Quit");
vMSExcel = Unassigned;
--
AEROPRODUCT
Didier BODINIER
Tel: 02.40.28.51.94
Fax: 02.40.28.53.87
Email dbodinier (AT) wanadoo (DOT) fr
Rue du 11 Novembre
BP1
44110 SOUDAN
Web Site http://www.aeroproduc.com
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> a écrit dans le message de news:
45827ea1$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
"Didier" <dbodinier (AT) wanadoo (DOT) fr> wrote in message
news:458276cd$1 (AT) newsgroups (DOT) borland.com...
I've made an evolution ogf my program (adding one thread) and now i get
the
next information windows when i try to conne ct to excel applicaton
_ASSERTE:
IsBound() failed-d:\bcb\emuvcl\ utilcls.h/4039
Are you trying to connec to Excel inside the thread? If so, then you call
CoInitialize() first?
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sat Dec 16, 2006 2:12 am Post subject: Re: pb with using excel com Object |
|
|
"Didier" <dbodinier (AT) wanadoo (DOT) fr> wrote in message
news:45829faf (AT) newsgroups (DOT) borland.com...
| Quote: | Here is my code which run in my first project !!!! and fails in my third
project
|
You did not say on which line in the code the error is occuring.
| Quote: | try
{
vMSExcel = Variant::GetActiveObject("Excel.Application");
}
catch(...)
{
vMSExcel = Variant::CreateObject("Excel.Application");
}
|
Don't use '...' to catch VCL exceptions. Catch them explicitally instead:
try
{
vMSExcel = Variant::GetActiveObject("Excel.Application");
}
catch(const Exception &)
{
try
{
vMSExcel = Variant::CreateObject("Excel.Application");
}
catch(const Exception &)
{
ShowMessage("Could not connect to Excel");
return;
}
}
Gambit |
|
| Back to top |
|
 |
Didier Guest
|
Posted: Sun Dec 17, 2006 6:39 pm Post subject: Re: pb with using excel com Object |
|
|
Hello
Here is the reason for which i get the error message explained in the
previous messages
I have deleted on progrma line
vXLWorkbooks =vMSExcel.OlePropertyGet("Workbooks");
this next line has disapeared :
vXLWorkbook=vXLWorkbooks.OleFunction("Open",vFileName);
vSheetName="Feuil1";
Ok this is normal to get an error message when i try to acces to "Feul1"
while I haven't opened workbook
What i don't understand is the message
first _ASSERTE window information IsBound @ d:\bcb\emuvcl\utilcls.h/4139
???
and next the error message Isbound() failed d:\bcb\emuvcl....
Can anybody explain me why i get these types message
Thank you |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Dec 19, 2006 1:48 am Post subject: Re: pb with using excel com Object |
|
|
"Didier" <bodinier.didier (AT) wanadoo (DOT) fr> wrote in message
news:45853a23 (AT) newsgroups (DOT) borland.com...
| Quote: | What i don't understand is the message
first _ASSERTE window information IsBound @ d:\bcb\emuvcl\utilcls.h/4139
???
and next the error message Isbound() failed d:\bcb\emuvcl....
|
The error is obvious when you think about it. The only way IsBound() can
return false is when the IDispatch pointer is NULL. Which means that the
Workbooks property is return NULL. Why that would be, I do not know. You
probably don't have a valid connection to Excel in the first place.
Gambit |
|
| Back to top |
|
 |
|