New to VSTO, know Excel’s model very well… I have
using Excel = Microsoft.Office.Interop.Excel;
at the head of my class, and the following simple call, which compiles correctly and even appears correct in intellisense
double usedRows = (double)Excel.WorksheetFunction.CountA(oWks.Columns[1]);
but fails at runtime with this exception
‘Microsoft.Office.Interop.Excel.WorksheetFunction’ does not contain a
definition for ‘CountA’
about which I can find little further information. What am I missing?
CountA needs to reference your Excel application instance, not the namespace (I think that’s the correct terminology).
So assuming you created or got and instance of Excel and called it oExcel then it’s:
… although I’m not a C person, so can’t confirm that the “(double)” part is correct.