 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Todd M. Eischeid Guest
|
Posted: Thu Dec 04, 2003 8:03 pm Post subject: Excel.exe Application Error when terminating app containing |
|
|
Hello,
I posted this message a few weeks back. I could really use the help. This
error is causing me major headaches, so I'm posting it again.
I have an BCB application that uses TExcelApplication. I read from an Excel
file with no problems. But when I terminate the application (e.g.,
Application->Terminate() ), I get an application error from Excel, one of
those "the memory could not be read" errors. I cannot for the life of me
figure this out. It's only after I terminate my application that I get the
error; I can manipulate Excel files with no problems while my app is running
and I never receive any errors. I call Disconnect at the end, as shown in
the code below, but it doesn't seem to do any good.
Has anyone ever experienced something like this?
Any help is appreciated.
Regards,
Todd Eischeid
********************************
//here is the code from when I shut down the app
ExcelWorksheet_tmp->Disconnect();
ExcelWorksheet1->Disconnect();
ExcelWorkbook1->Disconnect();
ExcelApplication1->Disconnect();
ExcelApplication1->Quit();
Application->ProcessMessages();
Application->Terminate();
********************************
|
|
| Back to top |
|
 |
Alain Pépin Guest
|
Posted: Thu Dec 11, 2003 9:34 pm Post subject: Re: Excel.exe Application Error when terminating app contain |
|
|
Here is a BCB5 code using TExcelApplication to set the value of a cell by
clicking a button. I hope this can help you!
Regards,
Alain
I use tree Excel components:
TExcelApplication *ExcelApp;
TExcelWorkbook *ExcelWb;
TExcelWorksheet *ExcelWs;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
ExcelApp->Connect(); //Start Excel
ExcelApp->Visible[TDefLCID()] = true; //Make Excel visible
ExcelApp->Workbooks->Add(); //Add a default workbook (with
3 sheets)
ExcelWb->ConnectTo(ExcelApp->Get_ActiveWorkbook());
ExcelWs->ConnectTo(ExcelApp->Get_ActiveSheet());
}
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
ExcelWb->Close(TVariant(false)); //Close without saving.
ExcelApp->Disconnect();
ExcelApp->Quit();
}
int ii=1;
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Excel_2k::RangePtr cell;
TVariant row, col;
row = 1;
col = 1;
cell = ExcelWs->Cells->get_Item(row, col);
cell->set_Value(TVariant(ii));
++ii;
}
"Todd M. Eischeid" <eischeid (AT) erols (DOT) com> wrote
| Quote: | Hello,
I have an BCB application that uses TExcelApplication. I read from an
Excel
file with no problems. But when I terminate the application (e.g.,
Application->Terminate() ), I get an application error from Excel, one of
those "the memory could not be read" errors. I cannot for the life of me
figure this out. It's only after I terminate my application that I get
the
error; I can manipulate Excel files with no problems while my app is
running
and I never receive any errors. I call Disconnect at the end, as shown in
the code below, but it doesn't seem to do any good.
|
|
|
| Back to top |
|
 |
Todd M. Eischeid Guest
|
Posted: Wed Dec 17, 2003 4:28 pm Post subject: Re: Excel.exe Application Error when terminating app contain |
|
|
Alain,
Thanks for your help. I'm unfortunately still getting the error. I'll just
pick through my code to see what I could be doing wrong.
Regards,
Todd Eischeid
"Alain Pépin" <apepin (AT) spn (DOT) ca> wrote
| Quote: | Here is a BCB5 code using TExcelApplication to set the value of a cell by
clicking a button. I hope this can help you!
Regards,
Alain
I use tree Excel components:
TExcelApplication *ExcelApp;
TExcelWorkbook *ExcelWb;
TExcelWorksheet *ExcelWs;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
ExcelApp->Connect(); //Start Excel
ExcelApp->Visible[TDefLCID()] = true; //Make Excel visible
ExcelApp->Workbooks->Add(); //Add a default workbook
(with
3 sheets)
ExcelWb->ConnectTo(ExcelApp->Get_ActiveWorkbook());
ExcelWs->ConnectTo(ExcelApp->Get_ActiveSheet());
}
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
ExcelWb->Close(TVariant(false)); //Close without saving.
ExcelApp->Disconnect();
ExcelApp->Quit();
}
int ii=1;
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Excel_2k::RangePtr cell;
TVariant row, col;
row = 1;
col = 1;
cell = ExcelWs->Cells->get_Item(row, col);
cell->set_Value(TVariant(ii));
++ii;
}
"Todd M. Eischeid" <eischeid (AT) erols (DOT) com> wrote in message
news:3fcf927a$1 (AT) newsgroups (DOT) borland.com...
Hello,
I have an BCB application that uses TExcelApplication. I read from an
Excel
file with no problems. But when I terminate the application (e.g.,
Application->Terminate() ), I get an application error from Excel, one
of
those "the memory could not be read" errors. I cannot for the life of
me
figure this out. It's only after I terminate my application that I get
the
error; I can manipulate Excel files with no problems while my app is
running
and I never receive any errors. I call Disconnect at the end, as shown
in
the code below, but it doesn't seem to do any good.
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|