PC Review


Reply
Thread Tools Rate Thread

Close excel application

 
 
=?Utf-8?B?bmVvcmV0?=
Guest
Posts: n/a
 
      8th Nov 2006
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)offApplObject;
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.
 
Reply With Quote
 
 
 
 
Arvi Laanemets
Guest
Posts: n/a
 
      8th Nov 2006
Hi

Try this:
....
excelAppl.Quit


--
Arvi Laanemets
( My real mail address: arvi.laanemets<at>tarkon.ee )



"neoret" <(E-Mail Removed)> wrote in message
news:1B294B54-429E-4629-AD25-(E-Mail Removed)...
>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)offApplObject;
> 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.



 
Reply With Quote
 
=?Utf-8?B?bmVvcmV0?=
Guest
Posts: n/a
 
      8th Nov 2006
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<at>tarkon.ee )
>
>
>
> "neoret" <(E-Mail Removed)> wrote in message
> news:1B294B54-429E-4629-AD25-(E-Mail Removed)...
> >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)offApplObject;
> > 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.

>
>
>

 
Reply With Quote
 
=?Utf-8?B?bmVvcmV0?=
Guest
Posts: n/a
 
      8th Nov 2006
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.CurrentCulture = 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<at>tarkon.ee )
> >
> >
> >
> > "neoret" <(E-Mail Removed)> wrote in message
> > news:1B294B54-429E-4629-AD25-(E-Mail Removed)...
> > >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)offApplObject;
> > > 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.

> >
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't close EXCEL from my VB.NET application =?Utf-8?B?U3RldmVT?= Microsoft VB .NET 7 5th Apr 2006 08:21 PM
close excel application Brian Microsoft Excel Programming 1 16th Jan 2006 08:09 AM
Trying to close Excel Application in IE =?Utf-8?B?UG9tbXk=?= Microsoft Excel Misc 3 24th Nov 2005 03:36 PM
macro to close excel application other than application.quit mary Microsoft Excel Programming 1 14th Sep 2004 03:43 PM
Close the Excel Application ahyui Microsoft Excel Programming 3 4th Jan 2004 08:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:30 PM.