ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to delete a sheet without Alert message (https://www.excelbanter.com/excel-programming/367663-how-delete-sheet-without-alert-message.html)

kvenku[_38_]

How to delete a sheet without Alert message
 

I use a VBS script to open a excel file and delete the sheets based o
some condition and Save and then close it.

The sampe script is

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True

On Error Resume Next
objExcel.workbooks.open "D:\FIPackageNEW.xls"

For Each ws In objExcel.Worksheets
If not ws.Name = "Sheet1" Then
ws.delete
End If
Next

objExcel.Save
objExcel = Nothing
objExcel.quit


I am getting a message (Data may exists in the sheet(s) selected fo
deletion. To premanently delete the data, press Delete) when i run thi
script. How to avoid this. There should not be any alert message whil
deleting the sheets.
Thanks in advance
__________________
Kalyana Venkatesh
Eagle Consulting


--
kvenk

I am VB programme
-----------------------------------------------------------------------
kvenku's Profile:
http://www.excelforum.com/member.php...nfo&userid=742
View this thread: http://www.excelforum.com/showthread.php?threadid=56280


colofnature[_96_]

How to delete a sheet without Alert message
 

Put

Application.DisplayAlerts = False

in the macro somewhere before the "ws.delete" line. This will suppres
any messages (Excel will automatically use the default).


Co

--
colofnatur
-----------------------------------------------------------------------
colofnature's Profile: http://www.excelforum.com/member.php...fo&userid=3435
View this thread: http://www.excelforum.com/showthread.php?threadid=56280


Tom Ogilvy

How to delete a sheet without Alert message
 
Just a caution that this will not work (when issued from an automation
client) in some versions of excel - possibly xl2000 and earlier.

--
Regards,
Tom Ogilvy


"colofnature" wrote:


Put

Application.DisplayAlerts = False

in the macro somewhere before the "ws.delete" line. This will suppress
any messages (Excel will automatically use the default).


Col


--
colofnature
------------------------------------------------------------------------
colofnature's Profile: http://www.excelforum.com/member.php...o&userid=34356
View this thread: http://www.excelforum.com/showthread...hreadid=562809




All times are GMT +1. The time now is 06:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com