I assume you're trying to call the Select
method on a Worksheet
and not the Linq Select
method or some other extension method.
The indexer for the Sheets
collection returns an object
since it can contain many different types of wheets (worksheets, charts, etc.) and there's not a common base type between those classes.
If you know that you are selecting a worksheet, use the Worksheets
property instead and explicitly cast it:
private static Excel.Application docExcel;
((Excel.Worksheets)docExcel.Worksheets[wsCount + 1]).Select();