ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Close excel application (https://www.excelbanter.com/excel-programming/377000-close-excel-application.html)

neoret

Close excel application
 
I have developed an addin using C#.

I need to close the application from my addin. I tired using the close
method like this:

private Microsoft.Office.Interop.Excel.Application excelAppl = null;
public Microsoft.Office.Interop.Excel.Workbook theActiveExcelWorkbook = null;

excelAppl = (Microsoft.Office.Interop.Excel.Application)offApp lObject;
theActiveWorkbook = excelAppl.ActiveWorkbook;

this.theActiveWorkbook.Close(false, false, missing);

That does noe work. The code is called but nothing happens. No error message
or nothing...

Do you have some advice for me on how to make this work.

Arvi Laanemets

Close excel application
 
Hi

Try this:
....
excelAppl.Quit


--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )



"neoret" wrote in message
...
I have developed an addin using C#.

I need to close the application from my addin. I tired using the close
method like this:

private Microsoft.Office.Interop.Excel.Application excelAppl = null;
public Microsoft.Office.Interop.Excel.Workbook theActiveExcelWorkbook =
null;

excelAppl = (Microsoft.Office.Interop.Excel.Application)offApp lObject;
theActiveWorkbook = excelAppl.ActiveWorkbook;

this.theActiveWorkbook.Close(false, false, missing);

That does noe work. The code is called but nothing happens. No error
message
or nothing...

Do you have some advice for me on how to make this work.




neoret

Close excel application
 
Yes, I've tried that. But then I quit every excel worksheet that is open...

My addin allows the user to archive the worksheet in an external archiving
system. The user may have many worksheets opened and I just want to close the
one he has just archived. Therefore I need to close the worksheet instance -
not the application.


"Arvi Laanemets" wrote:

Hi

Try this:
....
excelAppl.Quit


--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )



"neoret" wrote in message
...
I have developed an addin using C#.

I need to close the application from my addin. I tired using the close
method like this:

private Microsoft.Office.Interop.Excel.Application excelAppl = null;
public Microsoft.Office.Interop.Excel.Workbook theActiveExcelWorkbook =
null;

excelAppl = (Microsoft.Office.Interop.Excel.Application)offApp lObject;
theActiveWorkbook = excelAppl.ActiveWorkbook;

this.theActiveWorkbook.Close(false, false, missing);

That does noe work. The code is called but nothing happens. No error
message
or nothing...

Do you have some advice for me on how to make this work.





neoret

Close excel application
 
I found the problem...

I didn't have the close statement so I realy didn't see if there were any
exceptions thrown... And guess what - there were.

I got the "Old format or invalid type library. (Exception from HRESULT:
0x80028018 (TYPE_E_INVDATAREAD))" and had to set the culture to en-US.

For others needing the answer to this question, I changed the cultre info
like this:
System.Threading.Thread.CurrentThread.CurrentCultu re = new
System.Globalization.CultureInfo("en-US");

Now the current workbook closes - and not the excel application.


"neoret" wrote:

Yes, I've tried that. But then I quit every excel worksheet that is open...

My addin allows the user to archive the worksheet in an external archiving
system. The user may have many worksheets opened and I just want to close the
one he has just archived. Therefore I need to close the worksheet instance -
not the application.


"Arvi Laanemets" wrote:

Hi

Try this:
....
excelAppl.Quit


--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )



"neoret" wrote in message
...
I have developed an addin using C#.

I need to close the application from my addin. I tired using the close
method like this:

private Microsoft.Office.Interop.Excel.Application excelAppl = null;
public Microsoft.Office.Interop.Excel.Workbook theActiveExcelWorkbook =
null;

excelAppl = (Microsoft.Office.Interop.Excel.Application)offApp lObject;
theActiveWorkbook = excelAppl.ActiveWorkbook;

this.theActiveWorkbook.Close(false, false, missing);

That does noe work. The code is called but nothing happens. No error
message
or nothing...

Do you have some advice for me on how to make this work.






All times are GMT +1. The time now is 11:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com