How to get the name of the opening sheet in excel?

Hi all,

How to get the name of the active sheet in excel. I have an excel file with many sheet names but depending upon the situation only one name will come when we open the excel file. Is there any way we can get the active /current excel sheet name.?

FYI: i cannot use workbook.getsheet and loop it and get each name. What ever sheet name comes first while opening it must be displayed.

I tried using workbook.currentsheet.name but gets error " Object reference not set to an instance of an object."

While using workbook.getworkbooksheet(index) im getting the sheet name but is there any way we can get name name instead of this method?

Thanks in advance

hi @batBot,

I am sure there are other good ways to to it .

An Alternative is :slightly_smiling_face:

  1. Send Hotkey : Alt + H
  2. Send Hotkey : O
    3.Send Hotkey : R

This will select the Name of the Sheet .

  1. Then Ctrl + C - and you will have the sheet Name in clipboard.

–Mukesh

Hi @batBot,

Use Invoke VBA activity to get active sheetname. Follow below link for your reference:

Regards,
Senthil V.

@mukeshkala Thanks for the replay

Can we do this without interacting with excel?
I know that we can copy the sheet by opening the excel file but like (getworkboot sheet) is there any VBA script that we can use to get the active sheet name?

@Senthilkumar55

Thank you for the link I run the macro but it give the workbook name only.

Executing the script won’t open the excel file.

Yes. The shared link only returns the active sheet name alone. What else you need?

Regards,
Senthil V.

1 Like

While uisng invoke VBA activity to run the script i get this error Invoke VBA: Programmatic access to Visual Basic Project is not trusted.

Hey @batBot,

You need to change the Trust center settings in excel to run the script.

The detailed steps can be found in the below post :slight_smile:

1 Like