I'm trying to return worksheet properties based on a sheet name. If the name exists in the workbook then it returns all the properties a worksheet contains and if it can't find the sheet it will just return null.
I've tried to do this 2 separate ways.
1.
Excel.Worksheet sheet = (Excel.Worksheet)this.Sheets["Sheet2"];
Which gives me this error
'Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))'
var test = from s in Globals.ThisAddIn.Application.ActiveWorkbook.Worksheets
where s.Name.Equals("Sheet2")
select s;
Which returns nothing.
User contributions licensed under CC BY-SA 3.0