Hi Forum, I want to delete a Excel sheet using VBScript i tried the below script but still the below mentioned popup is coming while running the script ,
kindly suggest any solution using VBScript
Dim objExcel, objWorkbook, sheetName
sheetName = “Sheet1”
Set objExcel = CreateObject(“Excel.Application”)
objExcel.Visible = False
Set objWorkbook = objExcel.Workbooks.Open(“C:\Path\To\Your\Workbook.xlsx”)
objExcel.DisplayAlerts = False
On Error Resume Next
objWorkbook.Worksheets(sheetName).Delete
If Err.Number <> 0 Then
WScript.Echo “Error: Unable to delete the sheet.”
Err.Clear
End If
On Error GoTo 0
objExcel.DisplayAlerts = True
objWorkbook.Save
objWorkbook.Close
objExcel.Quit
Set objWorkbook = Nothing
Set objExcel = Nothing
Hi @sagar.singh1 ,Thanks for your response, do i have to run this on Invoke Code or invoke VBA activity?
Follow this approach.
-
Put your VBA code in a .text file
-
Use
Excel Process Scope
with these settings
-
Inside it use
Use Excel File
-
Use that file in Invoke VBA Code
Your code should look like this.
Hi @_nithish,
Use Invoke VBA Activity and follow the @ashokkarale instructions.
@ashokkarale code is right.