HRESULT: 0x800A03EC exception when trying to hide a sheet.

V

VVVVVK

Hi,

I am trying to set the visibility of an Excel sheet to xlSheetVeryHidden.
But I am getting an HRESULT: 0x800A03EC exception.

The code is given below:
Microsoft.Office.Interop.Excel.Application m_Excel;
Microsoft.Office.Interop.Excel.Workbook m_WorkBook;
Microsoft.Office.Interop.Excel.Worksheet m_worksheet;

m_Excel = new Application();
m_Excel.Visible = false;
m_Excel.DisplayAlerts = false;
m_WorkBook =
m_Excel.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
Worksheet sh = (Worksheet) m_WorkBook.Sheets[1];

sh.Visible = XlSheetVisibility.xlSheetVeryHidden;

At the last line above I get the exception. Stack Trace is here.

[COMException (0x800a03ec): Exception from HRESULT: 0x800A03EC.]
Microsoft.Office.Interop.Excel._Worksheet.set_Visible(XlSheetVisibility
RHS) +0
eMotion.DAM.Logic.Spreadsheet..ctor() in
c:\inetpub\wwwroot\excelop\export.cs:34
ExcelOp.WebForm1.ExcelWrite_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\excelop\webform1.aspx.cs:53
System.Web.UI.WebControls.Button.OnClick(EventArgs e)

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()

Does anyone know the solution. I just need to hide the sheet. That's all.

Thanks in Advance.
 
N

NickHK

How many worksheets do you have in the workbook ?
You can't hide the last one; one must be visible.

NickHK

VVVVVK said:
Hi,

I am trying to set the visibility of an Excel sheet to xlSheetVeryHidden.
But I am getting an HRESULT: 0x800A03EC exception.

The code is given below:
Microsoft.Office.Interop.Excel.Application m_Excel;
Microsoft.Office.Interop.Excel.Workbook m_WorkBook;
Microsoft.Office.Interop.Excel.Worksheet m_worksheet;

m_Excel = new Application();
m_Excel.Visible = false;
m_Excel.DisplayAlerts = false;
m_WorkBook =
m_Excel.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
Worksheet sh = (Worksheet) m_WorkBook.Sheets[1];

sh.Visible = XlSheetVisibility.xlSheetVeryHidden;

At the last line above I get the exception. Stack Trace is here.

[COMException (0x800a03ec): Exception from HRESULT: 0x800A03EC.]
Microsoft.Office.Interop.Excel._Worksheet.set_Visible(XlSheetVisibility
RHS) +0
eMotion.DAM.Logic.Spreadsheet..ctor() in
c:\inetpub\wwwroot\excelop\export.cs:34
ExcelOp.WebForm1.ExcelWrite_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\excelop\webform1.aspx.cs:53
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top