Unable to handle popup while deleting Excel sheet using VBScript

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


Hello @_nithish,

Use mansion code.

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?

@_nithish,

Follow this approach.

  1. Put your VBA code in a .text file

  2. Use Excel Process Scope with these settings

  3. Inside it use Use Excel File

  4. 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.