Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Nov 2002
    Thanked 0 Times in 0 Posts

    Catching what the user clicked (2000/SR1)

    When one makes changes to a document and clicks the Appliation close "X" one if prompt with a dialog asking if the user desires to save the document and the user has three options, "Yes", "No", "Canel"( see attachment ). Is there a way to catch the choice made by the user?

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Pittsburgh, Pennsylvania, USA
    Thanked 342 Times in 335 Posts

    Re: Catching what the user clicked (2000/SR1)

    What do you want to accomplish?

    You can get the affect by creating your own and ignoring excel's, like the example. It will prompt and then based on the response will tell you what it is and then do it.


    <pre>Option Explicit
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Dim iResponse As Integer
    iResponse = MsgBox(prompt:="Do you want to save the changes to " & ActiveWorkbook.Name, _
    Buttons:=vbYesNoCancel, _
    Title:="My Closing Question")
    Select Case iResponse
    Case vbYes
    MsgBox "I will save"
    Case vbNo
    MsgBox "I will Close, BUT NOT save"
    ActiveWorkbook.Saved = True
    Case vbCancel
    MsgBox "OK, try me later"
    Cancel = True
    End Select
    End Sub</pre>

Posting Permissions

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