BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Excel.exe Application Error when terminating app containing

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (ActiveX)
View previous topic :: View next topic  
Author Message
Todd M. Eischeid
Guest





PostPosted: Thu Dec 04, 2003 8:03 pm    Post subject: Excel.exe Application Error when terminating app containing Reply with quote



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





PostPosted: Thu Dec 11, 2003 9:34 pm    Post subject: Re: Excel.exe Application Error when terminating app contain Reply with 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

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





PostPosted: Wed Dec 17, 2003 4:28 pm    Post subject: Re: Excel.exe Application Error when terminating app contain Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (ActiveX) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.