Invoke Code for ActiveSheet Name

Hello Everyone,
I have a problem. I want to take the name of the active sheet from an open Excel file.
The best solution until now is Invoke Code and for the moment i manage to open the Excel file, but i dont know the code in VB.Net to take the name of the Active sheet.

This is the code:
Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
excel = New Microsoft.Office.Interop.Excel.Application ‘create the instance Of excel work book’

    wb = excel.Workbooks.Open(filename) 'Open the excel the file
    excel.Visible = True

Thank you in advance

@Ionut_Istrate

ws = CType(wb.ActiveSheet, Microsoft.Office.Interop.Excel.Worksheet)

1 Like

Thank you Vijay_Tulsalkar! It’s work!!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.