Custom MSGBOX Macro needed.
Upcoming Power Excel Seminars
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Custom MSGBOX Macro needed.

  1. #1
    New Member
    Join Date
    Mar 2002
    Location
    rejdus@hotmail.com
    Posts
    18
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    What would be a macro code if i want to create MsgBox
    with options ="yes" "no" "cancel"
    eg.
    Are you sure you want to go out from the application and save it>
    and then three choices to choose from
    YES NO CANCEL

    i seen that in my friend project and i fouund it better method than just the Exit button which would use macro like the one below:

    Sub Exit_button()
    '
    ' Exit_button Macro
    ' Takes you out of the application.
    '

    '
    ActiveWorkbook.Save
    ActiveWindow.Close
    End Sub

    thnx for help

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Posts
    117
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Sub CommandButton2_Click()
    Dim Ans As String
    Ans = MsgBox("Do you wish to terminate this program? (Program will be saved) If no, then program will exit without saving! However you will be prompted before closing to confirm 'NO' as your choice ", vbYesNoCancel)
    Select Case Ans
    Case vbYes
    Me.Hide
    Workbooks("YOUR NAME OF WORKBOOK").save
    Application.Quit

    Case vbNo
    Me.Hide
    Application.Quit

    Case vbCancel
    Me.Hide
    End Select
    Unload Me
    End Sub

    This code is written assuming a user hits a commandbutton to exit the program, then the promp reads as listed above.
    Hope this helps- Todd

  3. #3
    MrExcel MVP Russell Hauf's Avatar
    Join Date
    Feb 2002
    Location
    Portland, OR Area - USA
    Posts
    1,605
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-10 14:20, Mayk wrote:
    What would be a macro code if i want to create MsgBox
    with options ="yes" "no" "cancel"
    eg.
    Are you sure you want to go out from the application and save it>
    and then three choices to choose from
    YES NO CANCEL

    i seen that in my friend project and i fouund it better method than just the Exit button which would use macro like the one below:

    Sub Exit_button()
    '
    ' Exit_button Macro
    ' Takes you out of the application.
    '

    '
    ActiveWorkbook.Save
    ActiveWindow.Close
    End Sub

    thnx for help
    Something like this:

    Code:
    varResponse = MsgBox "Are you sure you want to go out from the application and save it?", vbYesNoCancel,"Confirm Close"
    
    Select Case varResponse
    Case No, Cancel
        Exit Sub
    Case Yes   ' do nothing (go on to next steps, the Save and Close).
    End Select
    -hth, Russell

    [ This Message was edited by: Russell Hauf on 2002-04-10 14:29 ]

  4. #4
    New Member
    Join Date
    Mar 2002
    Location
    rejdus@hotmail.com
    Posts
    18
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    todd
    me.hide
    and
    unload me
    causes problem
    because visual basic dont read it and taking it as an error.
    could u give me some kind of advice.

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com