Hi,
I want to delete an excel sheet from the file. And no, I don’t want to use the modern excel activity. Any vba code would work in my case.
hi @SunnyJha
please use the below code.
Application.DisplayAlerts = False
Activeworkbook.Sheets(“Data”).Delete
Application.DisplayAlerts = True
you can activate the workbook you want to delete the sheet or you can use thisworkbook specify the workbook name inside bracket.
or you can refer the below invoke VBA activity method.
- Inside the “Excel Application Scope,” add a “Invoke VBA” activity.
- In the properties of the “Invoke VBA” activity, write the following VB.NET code to delete the sheets:
Sub DeleteSheets()
Dim xlApp As Object
Dim xlWorkBook As Object
Dim xlWorkSheet As ObjectxlApp = CreateObject(“Excel.Application”)
xlWorkBook = xlApp.Workbooks.Open(“path_to_your_excel_file.xlsx”)Try
xlWorkBook.Worksheets(“Sheet2”).Delete()
xlWorkBook.Worksheets(“Sheet3”).Delete()
xlWorkBook.Worksheets(“Sheet4”).Delete()
Catch ex As Exception
’ Handle any exceptions here if necessary
End TryxlWorkBook.Save()
xlWorkBook.Close()
xlApp.Quit()
End Sub
refer the below video for your reference.
hope it helps!!!
Please refer the below link:
Hi @SunnyJha
You can also use Balareva Excel activities, install this package
& use this activity
Hope this helps
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.