ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   HRESULT: 0x800A03EC exception when trying to hide a sheet. (https://www.excelbanter.com/excel-programming/371421-hresult-0x800a03ec-exception-when-trying-hide-sheet.html)

VVVVVK

HRESULT: 0x800A03EC exception when trying to hide a sheet.
 
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.xlWBATWorkshee t);
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_Visi ble(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.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain()

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

Thanks in Advance.

NickHK

HRESULT: 0x800A03EC exception when trying to hide a sheet.
 
How many worksheets do you have in the workbook ?
You can't hide the last one; one must be visible.

NickHK

"VVVVVK" wrote in message
...
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.xlWBATWorkshee t);
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_Visi ble(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.IPo stBackEventHandler.RaisePo
stBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain()

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

Thanks in Advance.





All times are GMT +1. The time now is 09:15 PM.

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