Roger Alcindor
asked on
Excel COM Server connection does not close
I have an application written in Embarcadero C++ builder XE2 which uses the Excel Office COM server components that ship with the compiler.
It is a simple application that opens a spreadsheet and processes data from one of the spreadsheets.
I am using 3 components (TExcelWorksheet,TExcelWor kbook and TExcelApplication)
The application functions as it should but after the application has run, the task manager reveals that the Excel.exe *32 process is still running and this results in an erro when the application is subsequently run.
The destructor in the main form of my application contains the following code which I am using to close the Excel components but it would appear that this is not working.
ExcelWorksheet1->Disconnec t();
ExcelWorkbook1->Disconnect ();
ExcelApplication1->Quit();
ExcelApplication1->Disconn ect();
I have also tried the following:
ExcelWorksheet1->Disconnec t();
ExcelWorkbook1->Disconnect ();
ExcelApplication1->Disconn ect();
ExcelApplication1->Quit();
Is there a way to fix this ?
It is a simple application that opens a spreadsheet and processes data from one of the spreadsheets.
I am using 3 components (TExcelWorksheet,TExcelWor
The application functions as it should but after the application has run, the task manager reveals that the Excel.exe *32 process is still running and this results in an erro when the application is subsequently run.
The destructor in the main form of my application contains the following code which I am using to close the Excel components but it would appear that this is not working.
ExcelWorksheet1->Disconnec
ExcelWorkbook1->Disconnect
ExcelApplication1->Quit();
ExcelApplication1->Disconn
I have also tried the following:
ExcelWorksheet1->Disconnec
ExcelWorkbook1->Disconnect
ExcelApplication1->Disconn
ExcelApplication1->Quit();
Is there a way to fix this ?
ASKER
I have tried the following in the main form destructor and that doesn't fix the issue:
ExcelApplication1->Quit();
ExcelWorksheet1->Disconnec t();
ExcelWorkbook1->Disconnect ();
In C++ the main form destructor is where you place code to clean up and free any resources that have been used in the main form, in this case it is the Excel COM components that were used.
ExcelApplication1->Quit();
ExcelWorksheet1->Disconnec
ExcelWorkbook1->Disconnect
In C++ the main form destructor is where you place code to clean up and free any resources that have been used in the main form, in this case it is the Excel COM components that were used.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I discovered the fix by myself.
Do stuff with Excel
Quit Excel
Disconnect objects
?
Regards,
Zack Barresse