Click here to Skip to main content
15,923,374 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi,

I am exporting an excel file to my local disk. When I am trying to hide the excel work sheet, its throwing the following error :

Exception from HRESULT: 0x800A03EC


C#
foreach (Excel.Worksheet ws in wb.Worksheets)
{
   if (ws.Name.StartsWith("Sheet"))
      ws.Visible = XlSheetVisibility.xlSheetVeryHidden; // -->here the error is throwing exactly
   else
      ws.Protect("Nu*1", m, m, m, m, m, m, m, m, m, m, m, m, m, m, m);
}


I have gone through google also but I didn't get the solution. Any help would be appreciated

Thank you,
Pradeep Anugu.
Posted
Updated 14-Mar-12 7:48am
v3
Comments
shreekar 14-Mar-12 13:39pm    
Is the file already protected? Maybe you are trying to hide a sheet in a protected workbook or the worksheet itself is already protected?
ZurdoDev 14-Mar-12 13:59pm    
Or, is it the last visible sheet? Not sure what it would do if you hid every sheet.

1 solution

After about 3 minutes of Googling, you have two possibilities.

1) I've found references that say you cannot hide the last sheet in the workbook. I find this hard to believe, but nothing surprises me anymore. The workaround should be simple enough. Keep your user visible sheet the last sheet in the workbook. Put your hidden sheets first in the collection.

2) You must have at least one sheet visible at all times. If you try to hide the last visible sheet, this error will throw.
 
Share this answer
 
Comments
AnuguPradeep 14-Mar-12 15:46pm    
thanks a lot Mr.Dave. you are right! The last sheet should not be hidden...now I got the solution.
Rubaba 14-Mar-12 18:05pm    
5++

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900