Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
MsgBox Prompt w/ No "X" to close
hello:
this ng is great! Without _really_ knowing any "coding" I have been able to patch together the following from postings in this group: Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) ' Prevents use of the Close button If CloseMode = vbFormControlMenu Then Cancel = True ErrorBox = MsgBox("Would you like to close this workbook?", vbYesNo, "Error") If ErrorBox = YbYes Then ActiveWorkbook.Close ElseIf ErrorBox = YbNo Then Cancel = True End If End If End Sub However, when I hit the run button, the form pops up, and if I click the X in the top right corner of the form, the message box pops up. So far so good. But if I click on [Yes] it's no different than clicking [No]. [No] does what I want, but [Yes] doesn't close the book. Thanks for your help! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
MsgBox Prompt w/ No "X" to close
the constant is
vbYes rather than YbYes and vbNo rather than YbNo -- Regards, Tom Ogilvy "Pablo" wrote in message om... hello: this ng is great! Without _really_ knowing any "coding" I have been able to patch together the following from postings in this group: Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) ' Prevents use of the Close button If CloseMode = vbFormControlMenu Then Cancel = True ErrorBox = MsgBox("Would you like to close this workbook?", vbYesNo, "Error") If ErrorBox = YbYes Then ActiveWorkbook.Close ElseIf ErrorBox = YbNo Then Cancel = True End If End If End Sub However, when I hit the run button, the form pops up, and if I click the X in the top right corner of the form, the message box pops up. So far so good. But if I click on [Yes] it's no different than clicking [No]. [No] does what I want, but [Yes] doesn't close the book. Thanks for your help! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
MsgBox Prompt w/ No "X" to close
Try it this way:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) ' Prevents use of the Close button If CloseMode = vbFormControlMenu Then Cancel = True If MsgBox("Would you like to close this workbook?", vbYesNo, "Error") = vbYes Then ActiveWorkbook.Close ElseIf ErrorBox = YbNo Then Cancel = True End If End If End Sub -----Original Message----- hello: this ng is great! Without _really_ knowing any "coding" I have been able to patch together the following from postings in this group: Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) ' Prevents use of the Close button If CloseMode = vbFormControlMenu Then Cancel = True ErrorBox = MsgBox("Would you like to close this workbook?", vbYesNo, "Error") If ErrorBox = YbYes Then ActiveWorkbook.Close ElseIf ErrorBox = YbNo Then Cancel = True End If End If End Sub However, when I hit the run button, the form pops up, and if I click the X in the top right corner of the form, the message box pops up. So far so good. But if I click on [Yes] it's no different than clicking [No]. [No] does what I want, but [Yes] doesn't close the book. Thanks for your help! . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
MsgBox Prompt w/ No "X" to close
You have the Eagle eye my friend. :0)
-----Original Message----- the constant is vbYes rather than YbYes and vbNo rather than YbNo -- Regards, Tom Ogilvy "Pablo" wrote in message . com... hello: this ng is great! Without _really_ knowing any "coding" I have been able to patch together the following from postings in this group: Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) ' Prevents use of the Close button If CloseMode = vbFormControlMenu Then Cancel = True ErrorBox = MsgBox("Would you like to close this workbook?", vbYesNo, "Error") If ErrorBox = YbYes Then ActiveWorkbook.Close ElseIf ErrorBox = YbNo Then Cancel = True End If End If End Sub However, when I hit the run button, the form pops up, and if I click the X in the top right corner of the form, the message box pops up. So far so good. But if I click on [Yes] it's no different than clicking [No]. [No] does what I want, but [Yes] doesn't close the book. Thanks for your help! . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
is it possible to disable "save" prompt in excel file on web server? | Excel Discussion (Misc queries) | |||
Best way to trap error to MsgBox "Too many cell formats" | Excel Discussion (Misc queries) | |||
Disable "Save" &/or "Close" | Excel Programming | |||
How can I get "File Close" to prompt me to "Save Changes" ?? | Excel Programming |