Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default 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   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
is it possible to disable "save" prompt in excel file on web server? [email protected] Excel Discussion (Misc queries) 0 May 9th 07 05:58 PM
Best way to trap error to MsgBox "Too many cell formats" [email protected] Excel Discussion (Misc queries) 0 August 22nd 06 09:52 PM
Disable "Save" &/or "Close" universal[_4_] Excel Programming 3 October 25th 03 12:38 PM
How can I get "File Close" to prompt me to "Save Changes" ?? Charles Jordan Excel Programming 4 July 31st 03 04:01 PM


All times are GMT +1. The time now is 03:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"