I am having difficulties adding and renaming an excel sheet in a workbook, I went through some previous post referring to use hot keys activity, but that is not my mission. I like to use codes to solve the purpose.
workbookapplication.setSheet(sheetname as string, createnew as boolean)
I tried to use this code but did not get the success. Could someone help me to understand setSheet and getSheet method and is there any other method I should use to add and rename sheet?
— Fine to create a new sheet in excel a simple workaround is we can use use excel application scope activity and pass the file paste of the excel as input
— within this scope use a simple write cell or write range activity with the sheetname you want… with double quotes and it will create a new sheet in that excel
Invoke VBA is actually easier than you think. When it is inside an Excel Scope, it interacts with the window, so it’s just a matter of using the VB for changing the sheet name.
where “July 2019” is the sheet you want to change and “New Name” is the new name which both in the parameters can be variables
and that is the script file created in Notepad using .vbs extension.
I also looked some of it on google to find the syntax for referencing a sheet name in vbscript code
Since those are actions, you can try using the Invoke Method but I’m not familiar with getting those working in UiPath.
To rename the sheet as linked by @Palaniyappan, I normally use an alt-key combo, which performs the Rename Sheet feature from the ribbon menu.
So the keystroke combo is Alt, h, o, r, “New Name”, enter
If I see anything on using SetSheets, I’ll let you know.