How To Delete Excel Sheet Using Invoke Method?


How To Delete Excel Sheet Using Invoke Method ?

I found this link but didn’t hep, probably something is missing from my side :

Note : Please find bellow my example:
CheckIfSheetExistsThanDelete.xaml (9.1 KB) Example.xlsx (8.8 KB)

Thanks in advance

If you use the keystroke method (which I have used pretty well), you would want to do it probably with TypeIntos:
TypeInto activity: "[k(ralt)]hds"
with a delaybetweenkeys at maybe 20

Looking over your Invoke Code, there might be some issues with how it is opening the file inside an Excel Scope. However, I am a little busy to play around with your code.

Another option would be to use the Invoke VBA activity. This can be used inside the Excel Scope, and you would place your code in a .vbs file (using Notepad or script editors). Simply, you would just need to make a Function that performs the delete on the sheet. The code will be very simple in this case. I am not sure on the syntax but you can look up the vbscript for deleting a sheet. Maybe like this:

Function DeleteSheet()
End Function

Lastly, you can look at the Community feed for Manage Packages, as there are some Excel packages people created that may have a Delete Sheet activity. Also, search the forums.



EDIT: If you use keystroke method, make sure you use Select Range activity first to go to that sheet.

1 Like

Dear ClaytonM,

I have used your last option, I already have one excel package and it help on that. Thx
Meanwhile in case you have a complete invoke code please share it :slight_smile:

hi @hsendel

Here is a detailed article on that :slight_smile:
# How To Delete Sheets From An Excel File Programmatically – In UiPath



Hi @ClaytonM

I need to pass the sheetname dynamically. So, is there any chance to keep the sheet name dynamic instead of Test.