Steve,
a) What is 'this'? A form?
b) Show us the Dispose methods in the class.
c) It seems odd that line 5 is saving after line 4 has quit.
d) Note that the way you have written the code that Excel
won't unload
itself from memory until the GC cleans up all the RCWs. You
may want to
read up on ReleaseCOMObject.
Seeya
Matthew Wills | Senior Analyst Programmer | Adviser Tools
and Services|
Financial Planning and Third Party | NAB Technology | Wealth
Management
Australia
|---------+---------------------------->
| | Steve Abaffy |
| | <steve MSMARKETIN|
| | G.BIZ> |
| | |
| | |
|---------+---------------------------->
>--------------------------------------------------------
------------------------------------------------------|
|
|
| To: DOTNET-WINFORMS DISCUSS.DEVELOP.COM
|
| cc:
|
| Subject: [DOTNET-WINFORMS] Excel Error
|
>--------------------------------------------------------
------------------------------------------------------|
Hello,
I get the following HRESULT: 0x800A03EC error at
line 6 of this
function.
private void btnClose_Click(object sender, System.EventArgs
e)
{
1 string filename = this.ofdExcel.FileName.ToString();
2 filename =
filename.Substring(0,filename.IndexOf(".")-1);
3 ExcelObj.Workbooks.Close();
4 ExcelObj.Quit();
5 ExcelObj.Save(filename + "zip4Added.xls");
6 this.Dispose();
}
The declaration of ExcelObj is Excel.Application ExcelObj =
new
Excel.Application();
If is say continue to the error the application closes
normally and all
changes made to the Excel spreadsheet are there. Just don't
understand why
I
am getting the error. Searching at Microsoft.com did not
reveal anything
useful. So I was wondering if any of you have had a similar
experience?
____________________________________________________________
__________
This email has been scanned by the MessageLabs Email
Security System.
For more information please visit http://www.messagela
bs.com/email
____________________________________________________________
__________
This e-mail is sent by or on behalf of the named sender
identified above.
If:
(a) you do not wish to receive any e-mail marketing material
from this
person in the future, please forward the contents of this
email to
unsubscribe mlc.com.au with the word "unsubscribe" in
the
subject box.
(b) you wish to unsubscribe from all central e-mail
marketing lists
used by our business, please forward the contents of this
e-mail to
unsubscribeall mlc.com.au with the message
"unsubscribe
from all central e-mail marketing lists" in the subject
box.
If you do not forward the contents of this e-mail with your
unsubscription then it may not be able to be implemented.
The information contained in this e-mail communication may
be
confidential. You should only read, disclose, re-transmit,
copy,
distribute, act in reliance on or commercialise the
information if you
are authorised to do so. If you are not the intended
recipient of this
e-mail communication, please immediately notify us by e-mail
to
postmaster mlc.com.au, or reply by e-mail direct to the sender
and then
destroy any electronic and paper copy of this message. Any
views
expressed in this e-mail communication are those of the
individual
sender, except where the sender specifically states them to
be the views
of a member of the National Australia Bank Group of
companies. Any
advice contained in this e-mail has been prepared without
taking into
account your objectives, financial situation or needs.
Before acting on
any advice in this e-mail, National Australia Bank Limited
recommends
that you consider whether it is appropriate for your
circumstances. If
this e-mail contains reference to any financial products,
the National
recommends you consider the Product Disclosure Statement
(PDS) or other
disclosure document before making any decisions regarding
any products.
The National Australia Bank Group of companies does not
represent,
warrant or guarantee that the integrity of this
communication has been
maintained nor that the communication is free of errors,
virus or
interference. |