Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Userform Question

How do I disable the close button (X button) at the top-right corner of a
user form? I looked for it in the form properties, and I didn't find it.

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Userform Question

There is no form property to disable this option. You can only do this via
an API call. Alternatively you can intercept the user pressing the button
and choose to ignore it. e.g.

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then Cancel = True
End Sub



--

Regards,
Nigel




"Please Help" wrote in message
...
How do I disable the close button (X button) at the top-right corner of a
user form? I looked for it in the form properties, and I didn't find it.

Thanks.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Userform Question

Hi Nigel,

Thanks for the code.

First of all, where do I use the code? Is it in "ThisWorkbook" or the form
in Visual Basic?

Secondly, what would you suggest on handling the situation below?

I created a user form, and when the workbook containing the user form opens,
the workbook will be hidden. On the user form, I have a close command
button, and when the user clicks on it, it will close the user form as well
as the workbook. However, when the user clicks on the top-right corner of X
button, the form closes but the workbook does not close. How should I do
either just to have my command button active or to close the workbook when
the user clicks on the X button?

Thanks.



"Nigel" wrote:

There is no form property to disable this option. You can only do this via
an API call. Alternatively you can intercept the user pressing the button
and choose to ignore it. e.g.

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then Cancel = True
End Sub



--

Regards,
Nigel




"Please Help" wrote in message
...
How do I disable the close button (X button) at the top-right corner of a
user form? I looked for it in the form properties, and I didn't find it.

Thanks.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Userform Question

Hi Nigel,

I answered my questions. Your code works perfectly with what I was looking
for.

Thanks again.

"Nigel" wrote:

There is no form property to disable this option. You can only do this via
an API call. Alternatively you can intercept the user pressing the button
and choose to ignore it. e.g.

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then Cancel = True
End Sub



--

Regards,
Nigel




"Please Help" wrote in message
...
How do I disable the close button (X button) at the top-right corner of a
user form? I looked for it in the form properties, and I didn't find it.

Thanks.


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
Userform question lonnied Excel Programming 0 February 5th 06 02:37 AM
UserForm Question bforster1[_25_] Excel Programming 1 November 6th 04 01:21 PM
Userform question David Goodall Excel Programming 1 May 16th 04 03:25 PM
Userform question David Goodall Excel Programming 5 May 12th 04 10:18 AM
UserForm Question abxy[_16_] Excel Programming 2 February 5th 04 07:11 PM


All times are GMT +1. The time now is 07:37 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"