Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
AOU AOU is offline
external usenet poster
 
Posts: 54
Default Userform close button

Is there a way to disable the close button top right of a userform. I am
after the user only being able to use a commandbutton titled 'Exit'
--
AOU
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 61
Default Userform close button

try this

Private Sub Userform_QueryClose(Cancel As Integer, closeMode As Integer)
If closeMode = 0 Then
Cancel = True
MsgBox "Please use the button!"
End If
End Sub


"AOU" wrote:

Is there a way to disable the close button top right of a userform. I am
after the user only being able to use a commandbutton titled 'Exit'
--
AOU

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 61
Default Userform close button

try this

Private Sub Userform_QueryClose(Cancel As Integer, closeMode As Integer)
If closeMode = 0 Then
Cancel = True
MsgBox "Please use the button!"
End If
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Userform close button

As a user, I'm accustomed to using that X to close the form. Why make it more
difficult for me? Your userform could call the commandbutton_click procedure
associated with the Exit button.

Option Explicit
Private Sub CommandButton2_Click()
'clean up whatever you need to here.
Unload Me
End Sub
Private Sub Userform_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Call CommandButton2_Click
End If
End Sub



AOU wrote:

Is there a way to disable the close button top right of a userform. I am
after the user only being able to use a commandbutton titled 'Exit'
--
AOU


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
AOU AOU is offline
external usenet poster
 
Posts: 54
Default Userform close button

Thanks Dave.
But if I close the userfrom using the X it doesn`t save the data on the
textboxes. So the reason to use the commandbutton is to hide the userform so
that when opening it agian it has the details last entered.
--
AOU


"Dave Peterson" wrote:

As a user, I'm accustomed to using that X to close the form. Why make it more
difficult for me? Your userform could call the commandbutton_click procedure
associated with the Exit button.

Option Explicit
Private Sub CommandButton2_Click()
'clean up whatever you need to here.
Unload Me
End Sub
Private Sub Userform_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Call CommandButton2_Click
End If
End Sub



AOU wrote:

Is there a way to disable the close button top right of a userform. I am
after the user only being able to use a commandbutton titled 'Exit'
--
AOU


--

Dave Peterson



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
Close automatically a userform FARAZ QURESHI Excel Discussion (Misc queries) 4 January 7th 07 07:46 PM
auto close userform AOU Excel Discussion (Misc queries) 0 December 23rd 06 10:36 PM
Userform + close button Chip Smith Excel Discussion (Misc queries) 2 April 1st 06 09:35 AM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
excel - Windows close button (x) should only close active workboo. CoffeeAdict Setting up and Configuration of Excel 3 February 8th 05 04:30 AM


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

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

About Us

"It's about Microsoft Excel"