Board index » delphi » closing Excel

closing Excel


2003-10-23 07:16:04 PM
delphi92
Hi,
Can anyone please help me with my Excel problem.
Excel hang around in memory until I close my program.
Thanks,
Leen
ExcelApplication1 = new TExcelApplication (this);
ExcelWorkbook = new TExcelWorkbook (this);
ExcelWorksheet = new TExcelWorksheet (this);
ExcelApplication1->Connect ();
ExcelApplication1->Workbooks->Open(TVariant(File));
ExcelWorkbook->ConnectTo(ExcelApplication1->Workbooks->get_Item(TVariant(1))
);
ExcelWorksheet->ConnectTo(ExcelWorkbook->Sheets->get_Item(TVariant(1)));
ExcelWorksheet->Activate ();
ExcelWorksheet->Cells->SpecialCells(xlCellTypeLastCell,
EmptyParam)->Activate ();
ExcelWorksheet->Disconnect ();
ExcelApplication1->Workbooks->Close ();
ExcelWorkbook->Disconnect ();
ExcelApplication1->Disconnect ();
delete ExcelWorksheet;
delete ExcelWorkbook;
delete ExcelApplication1;
 
 

Re:closing Excel

<<Leen Hallaert:
Excel hang around in memory until I close my program.
Quote
>
Your code as shown doesn't call the Excel.Quit method. You
need to do that before calling Disconnect.
--
Deborah Pate (TeamB) delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
www.borland.com/newsgroups/genl_faqs.html
 

Re:closing Excel

I doesn't help,
Excel still hang around in memory until I close my program.
"Deborah Pate (TeamB)" <XXXX@XXXXX.COM>schreef in
bericht news:XXXX@XXXXX.COM...
Quote
<<Leen Hallaert:
Excel hang around in memory until I close my program.
>>

Your code as shown doesn't call the Excel.Quit method. You
need to do that before calling Disconnect.

--
Deborah Pate (TeamB) delphi-jedi.org

TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
www.borland.com/newsgroups/genl_faqs.html


 

Re:closing Excel

<<Leen Hallaert:
Excel still hang around in memory until I close my program.
Quote
>
If you were using Delphi I would say you still had a 'live'
variable of some kind that referred to an Excel object, and
you needed to clear it. I have a dim memory, however, of
there being a further catch in BCB - so you probably need
to ask in the borland.public.cppbuilder.activex newsgroup.
--
Deborah Pate (TeamB) delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
www.borland.com/newsgroups/genl_faqs.html
 

Re:closing Excel

Until here it is ok:
ExcelApplication1 = new TExcelApplication (NULL);
ExcelApplication1->Connect ();
ExcelApplication1->Workbooks->Open(TVariant(File));
ExcelApplication1->Workbooks->Close ();
ExcelApplication1->Quit ();
ExcelApplication1->Disconnect ();
delete ExcelApplication1;
Excel doesn't hang around in memory
when I add the following line
ExcelApplication1->Workbooks->get_Item(TVariant(1))->Sheets->get_Item(TVaria
nt(1));
Excel hang around in memory.
Is there a way to close or delete the Worksheets?
thanks,
Leen
 

Re:closing Excel

<<Leen Hallaert:
Is there a way to close or delete the Worksheets?
Quote
>
You could try calling Release for them. I found some code
like this in Google:
The solution to the leak is to do something like this:
WorksheetPtr wsheet = wsheets->get_Item (1);
LPDISPATCH p = wsheet;
wsheet->Release ();
--
Deborah Pate (TeamB) delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
www.borland.com/newsgroups/genl_faqs.html
 

Re:closing Excel

It doesn't help.
Thanks,
Leen