Get sheetname without scope

Hello everyone.

I am trying to get sheetname of a excel with invoke code ( I know there is an activity with excel scope ti get sheetname but i am trying to dont use it). The code it is this one
Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook excelBook = xlApp.Workbooks.Open(filename);
String hojas = new String[excelBook.Worksheets.Count];
int i = 0;
foreach(Microsoft.Office.Interop.Excel.Worksheet wSheet in excelBook.Worksheets)
{
hojas[i] = wSheet.Name;
i++;
}
filename it is a string in argument, it is the path

hojas it is string out argument, there are the sheetnames

I am getting CS0136 error and i dont know why

Than youu!!!

hi @jagoba.barata

For Each worksheet In WorkBook.Sheets
LastRow=MasterWorkSheet.UsedRange.Rows.Count
If worksheet.Name.Contains(“Macro”) Or worksheet.Name.Contains(“MasterConsolidated”) Then

Else
TempSheetLastRow=worksheet.UsedRange.Rows.Count
Console.WriteLine(worksheet.Name+TempSheetLastRow.ToString)
End If

Next worksheet
This works!!!

1 Like