Excel file + Multiple Sheets + Always open on first sheet + VBA

I have a excel file with multiple sheets. I do some operations on all sheets and save the file.

When the bot saves and opens the file it opens on the last saved sheet. Like below
image

But user always wants to open the excel file on the first sheet. Like below
image

Can anyone help me with this…

I tried using VBA as below:

Sub FistSheet()
Worksheets(“Test1”).Activate
End Sub

But this is not working…

Hello @Sairam_RPA ,

Did you try this vba code?

Thanks!
Athira

1 Like

Which one solution for this post

Use the below code in invoke code.
Then pass your input file in in_Path argument in invoke code activity

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
wb = excel.Workbooks.Open(in_Path)
excel.Visible = False
ws = CType(wb.Sheets(“Sheet1”), Microsoft.Office.Interop.Excel.Worksheet)
ws.Activate()
wb.Save()
wb.Close()
excel.Quit()

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