+ Reply to Thread
Results 1 to 3 of 3

Delete worksheet with no user prompt with VBA

  1. #1
    Graham Whitehead
    Guest

    Delete worksheet with no user prompt with VBA

    Is there anyway I can prevent the user prompt from appearing when I use code
    to delete a worksheet? thanks.



  2. #2

    Re: Delete worksheet with no user prompt with VBA

    taken from the help file

    DisplayAlerts Property
    See Also Applies To Example Specifics
    True if Microsoft Excel displays certain alerts and messages while a
    macro is running. Read/write Boolean.

    Remarks
    The default value is True. Set this property to False if you don't
    want to be disturbed by prompts and alert messages while a macro is
    running; any time a message requires a response, Microsoft Excel
    chooses the default response.

    If you set this property to False, Micorosoft Excel sets this property
    to True when the code is finished, unless you are running cross process
    code.

    When using the SaveAs method for workbooks to overwrite an existing
    file, the 'Overwrite' alert has a default of 'No', while the 'Yes'
    response is selected by Excel when the DisplayAlerts property is set
    equal to True.

    Example
    This example closes the workbook Book1.xls and doesn't prompt the
    user to save changes. Any changes to Book1.xls aren't saved.

    Application.DisplayAlerts = False
    Workbooks("BOOK1.XLS").Close
    Application.DisplayAlerts = True
    This example suppresses the message that otherwise appears when you
    initiate a DDE channel to an application that's not running.

    Application.DisplayAlerts = False
    channelNumber = Application.DDEInitiate( _
    app:="WinWord", _
    topic:="C:\WINWORD\FORMLETR.DOC")
    Application.DisplayAlerts = True
    Application.DDEExecute channelNumber, "[FILEPRINT]"
    Application.DDETerminate channelNumber
    Application.DisplayAlerts = True

    Graham Whitehead wrote:
    > Is there anyway I can prevent the user prompt from appearing when I use code
    > to delete a worksheet? thanks.



  3. #3
    Gord Dibben
    Guest

    Re: Delete worksheet with no user prompt with VBA


    Graham

    Sub SheetDelete()
    Application.DisplayAlerts = False
    ActiveWindow.SelectedSheets.Delete
    Application.DisplayAlerts = True
    End Sub


    Gord Dibben MS Excel MVP

    On Wed, 21 Jun 2006 14:17:37 +0100, "Graham Whitehead"
    <[email protected]> wrote:

    >Is there anyway I can prevent the user prompt from appearing when I use code
    >to delete a worksheet? thanks.
    >



+ 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