![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: =ActiveCell.Address
Posts: 478
|
I've created a couple of userforms with input boxes, Ok and Cancel buttons etc. which are now working fine. However, the one oddity that I can't work out is where to put code that controls what happens when the used clicks on the X at the top right of the form. Basically I would want to use the same code as I have under my Cancel button but all that happens is the macro continues along to the next stage. Any help, gratefully received. Thanks AJ |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Posts: 81
|
hi,
try putting this bit of code: Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) ' Prevents use of the Close button If CloseMode = vbFormControlMenu Then MsgBox "Clicking the Close button does not work." Cancel = True End If End Sub anywhere in the userform's code section i think that the code is self explanitory and you can change it to whatever! Ed |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Location: Little Italy
Posts: 93
|
Put this on the UserForm:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = vbFormControlMenu Then Cancel = True End If *Put your code here* End Sub |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Mar 2002
Location: Little Italy
Posts: 93
|
Oops! Sorry Jackeb, didn't notice that you had already given the same exact answer...
|
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Mar 2002
Location: =ActiveCell.Address
Posts: 478
|
Perfect. Thanks very much to you both. |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Mar 2002
Posts: 81
|
no probs.. a time conflict, just glad that we agree!!
Ed |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|