Vb.net : Interop exception when showAllData() on Excel sheet?
I have some filters applied on my input excel sheets, so I decided to remove them using showAllData() method in vb.net.
MSDN Reference : http://msdn.microsoft.com/en-us/library/bb178108(v=office.12).aspx
But it is giving a very strange exception on that line : Exception from HRESULT: 0x800A03EC
My code :
sh = myWorkBook.Sheets(2) ' sh is my sheet sh.Visible = True sh.Activate() sh.Select() sh.ShowAllData() ' Exception raised on this line
What am I doing wrong ?
What is this exception, I have seen this a lot lately. But its never clear what went wrong ?
Got it fixed :
The sheets that I was using for input didn't had filtered data when tested.
So, here goes the code change :
sh = myWorkBook.Sheets(2) ' sh is my sheet sh.Visible = True sh.Activate() sh.Select() If sh.FilterMode = True Then sh.ShowAllData() End If
The extra if, solved the issue.
But still the raised exception was not at all helpful. Explain the exception if someone can.