Thread: MsgBox
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Robert Rosenberg[_2_] Robert Rosenberg[_2_] is offline
external usenet poster
 
Posts: 24
Default MsgBox

No. You need to create a Userform for that. However, why not change your
tact and promt the user with the following message:

"Do you want to Close and Save the Workbook?"

Then use either the Yes/No or OK/Cancel buttons on the message box (see
below for an example)

Sub MessageBoxExampleForCloseAndSave()

Dim lAnswer As Long

'Assume the answer will be Cancel
lAnswer = vbCancel
'Prompt the user
'Note: I want to show both the exclamation icon AND the OK/Cancel
buttons in the message box.
' I used a plus (vbExclamation + vbOKCancel) to add both.
lAnswer = MsgBox("Do you want to Close and Save the Workbook?",
vbExclamation + vbOKCancel, "Close and Save")

'Close and save the workbook if the user click OK
If lAnswer = vbOK Then ActiveWorkbook.Close True

End Sub
--
_______________________
Robert Rosenberg
R-COR Consulting Services
Microsoft MVP - Excel

"Ed" wrote in message
...
Hi

Is it possible to have a Msgbox pop up with two
options "Close and Save Workbook" and "Keep working on
Workbook"

Obviously when someclicks on "Close and Save Workbook" it
will close and save it.