Invoke code activity in editing excel file

Hello all.
I’m trying to utilize the invoke code activity to run the following code:
Dim xlApp As New Excel.Application
Dim workbook As Excel.Workbook
Dim sheet As Excel.Worksheet

    xlApp.Visible = True
    workbook = xlApp.Workbooks.Open("exceldata.xlsx")
    sheet = workbook.Worksheets(1)

    'filter
    sheet.Range("A1:B23").AutoFilter(Field:=2, Criteria1:="5", Operator:=Excel.XlAutoFilterOperator.xlTop10Items)
    sheet.SaveAs("exceldata2.xlsx")

I am getting the following error:
image

I have added the Microsoft.Office.Interop,Excel on the imports tab. still have those errors.
Hope you can help.
Thanks

From the looks of it you are trying to invoke the method .Visible on a String object, but the String Class doesn’t contain that method. You need to change your object type. Edit: I didn’t see that you already created the variables as excel objects. I would say check the variable pane and make sure it matches what you are wanting each variable to be.

Here is a link to some info about working with Excel application objects.

https://www.tutorialspoint.com/vb.net/vb.net_excel_sheet.htm

I found another workaround.
Anyways, thank you so much for your response

Hi @marj0sa

Feel free to share your workaround :slight_smile: