+ Reply to Thread
Results 1 to 3 of 3

How to delete a sheet without Alert message

  1. #1
    Registered User
    Join Date
    03-22-2004
    Location
    Chennai
    Posts
    1

    How to delete a sheet without Alert message

    I use a VBS script to open a excel file and delete the sheets based on 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 for deletion. To premanently delete the data, press Delete) when i run this script. How to avoid this. There should not be any alert message while deleting the sheets.
    Thanks in advance
    __________________
    Kalyana Venkatesh
    Eagle Consulting
    [email protected]
    Kalyana Venkatesh
    Eagle Consulting
    [email protected]

  2. #2
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    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

  3. #3
    Tom Ogilvy
    Guest

    Re: 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
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1