Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Diable close button
A close button is automatically inserted on a UserForm. How can I prevent
this. I want to control the closing of the form only through the use of OK or Cancel. |
#2
|
|||
|
|||
What do you mean by "automatically"? I wasn't aware that anything appeared
on a UserForm unless you put it there. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA Word MVP FAQ site: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. "Cor van der Bliek" wrote in message news A close button is automatically inserted on a UserForm. How can I prevent this. I want to control the closing of the form only through the use of OK or Cancel. |
#3
|
|||
|
|||
A UserForm gets a Close button (the normal X on the right top) by default.
Pushing this button closed the form without programmable interaction. That is what I want to prevent. I want to always be able to control the way the form is closed. "Suzanne S. Barnhill" wrote: What do you mean by "automatically"? I wasn't aware that anything appeared on a UserForm unless you put it there. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA Word MVP FAQ site: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. "Cor van der Bliek" wrote in message news A close button is automatically inserted on a UserForm. How can I prevent this. I want to control the closing of the form only through the use of OK or Cancel. |
#4
|
|||
|
|||
Hi Cor,
See http://word.mvps.org/faqs/userforms/...loseButton.htm for a simple bit of code to prevent the X button from doing anything. There isn't any way to remove the button itself. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Cor van der Bliek wrote: A UserForm gets a Close button (the normal X on the right top) by default. Pushing this button closed the form without programmable interaction. That is what I want to prevent. I want to always be able to control the way the form is closed. "Suzanne S. Barnhill" wrote: What do you mean by "automatically"? I wasn't aware that anything appeared on a UserForm unless you put it there. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA Word MVP FAQ site: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. "Cor van der Bliek" wrote in message news A close button is automatically inserted on a UserForm. How can I prevent this. I want to control the closing of the form only through the use of OK or Cancel. |
#5
|
|||
|
|||
Since it can't be removed, let's give it something useful to do:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then Cancel = True MsgBox "Use the OK or Cancel button to close this form" End Sub Thanks. "Jay Freedman" wrote: Hi Cor, See http://word.mvps.org/faqs/userforms/...loseButton.htm for a simple bit of code to prevent the X button from doing anything. There isn't any way to remove the button itself. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Cor van der Bliek wrote: A UserForm gets a Close button (the normal X on the right top) by default. Pushing this button closed the form without programmable interaction. That is what I want to prevent. I want to always be able to control the way the form is closed. "Suzanne S. Barnhill" wrote: What do you mean by "automatically"? I wasn't aware that anything appeared on a UserForm unless you put it there. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA Word MVP FAQ site: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. "Cor van der Bliek" wrote in message news A close button is automatically inserted on a UserForm. How can I prevent this. I want to control the closing of the form only through the use of OK or Cancel. |
#6
|
|||
|
|||
Ah, I wasn't thinking of the X but rather an actual button. Thanks for the
clarification (and see Jay's post for an actual answer). -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA Word MVP FAQ site: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. "Cor van der Bliek" wrote in message ... A UserForm gets a Close button (the normal X on the right top) by default. Pushing this button closed the form without programmable interaction. That is what I want to prevent. I want to always be able to control the way the form is closed. "Suzanne S. Barnhill" wrote: What do you mean by "automatically"? I wasn't aware that anything appeared on a UserForm unless you put it there. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA Word MVP FAQ site: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. "Cor van der Bliek" wrote in message news A close button is automatically inserted on a UserForm. How can I prevent this. I want to control the closing of the form only through the use of OK or Cancel. |
#7
|
|||
|
|||
Hi Cor,
Well, not quite. That would display the message whenever the user closes the userform, regardless of how they did it. I'd find that annoying if I actually had clicked OK or Cancel. What you want is this: Private Sub UserForm_QueryClose(Cancel As Integer, _ CloseMode As Integer) If CloseMode = vbFormControlMenu Then Cancel = True MsgBox "Use the OK or Cancel button to close this form" End If End Sub An alternative would be to assume that the X button should be the equivalent of the Cancel button, and just do it: Private Sub UserForm_QueryClose(Cancel As Integer, _ CloseMode As Integer) If CloseMode = vbFormControlMenu Then btnCancel_Click End If End Sub If you've renamed the Cancel button to something other than btnCancel, alter this as necessary. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Cor van der Bliek wrote: Since it can't be removed, let's give it something useful to do: Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then Cancel = True MsgBox "Use the OK or Cancel button to close this form" End Sub Thanks. "Jay Freedman" wrote: Hi Cor, See http://word.mvps.org/faqs/userforms/...loseButton.htm for a simple bit of code to prevent the X button from doing anything. There isn't any way to remove the button itself. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Cor van der Bliek wrote: A UserForm gets a Close button (the normal X on the right top) by default. Pushing this button closed the form without programmable interaction. That is what I want to prevent. I want to always be able to control the way the form is closed. "Suzanne S. Barnhill" wrote: What do you mean by "automatically"? I wasn't aware that anything appeared on a UserForm unless you put it there. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA Word MVP FAQ site: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. "Cor van der Bliek" wrote in message news A close button is automatically inserted on a UserForm. How can I prevent this. I want to control the closing of the form only through the use of OK or Cancel. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Why does the program close when a file is closed? | Microsoft Word Help | |||
Lost mail merge function button | Mailmerge | |||
paste options button no longer visible | Microsoft Word Help | |||
Close Button in Word | Microsoft Word Help | |||
Command button won't work on locked form. | Page Layout |