I am working on an Excel VSTO application and detect cell cells in worksheets using the code below
Excel.Range rngTemp;
Excel.Range rngErrorRange;
Excel._Worksheet Sheet1 = (Excel._Worksheet)xlCTA.Sheets["Sheet1"];
rngTemp = wsCTAWK11.UsedRange;
rngErrorRange = rngTemp.SpecialCells(Excel.XlCellType.xlCellTypeFormulas, Excel.XlSpecialCellsValue.xlErrors);
when the error cells are actually detected, I have no problems, but when I have no error cells in this sheet, I get the following exception.
**threw an exception of type 'System.Runtime.InteropServices.COMException'
base {System.Runtime.InteropServices.ExternalException}: {"No cells were found."}**
How to handle this ... Pls Help
source
share