#1   Report Post  
Cor van der Bliek
 
Posts: n/a
Default 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   Report Post  
Suzanne S. Barnhill
 
Posts: n/a
Default

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   Report Post  
Cor van der Bliek
 
Posts: n/a
Default

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   Report Post  
Jay Freedman
 
Posts: n/a
Default

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   Report Post  
Cor van der Bliek
 
Posts: n/a
Default

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   Report Post  
Suzanne S. Barnhill
 
Posts: n/a
Default

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   Report Post  
Jay Freedman
 
Posts: n/a
Default

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does the program close when a file is closed? Carmie Microsoft Word Help 1 January 19th 05 10:19 PM
Lost mail merge function button Robert Judge Mailmerge 1 January 11th 05 05:22 AM
paste options button no longer visible Wendy Microsoft Word Help 3 January 8th 05 10:31 AM
Close Button in Word JohnDeeze Microsoft Word Help 1 November 30th 04 06:32 PM
Command button won't work on locked form. Angie Page Layout 1 November 29th 04 02:13 PM


All times are GMT +1. The time now is 03:41 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"