Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
UserForm 2
Hello,
Is there a way to eliminate the close button [X] at the top right of the userform? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
UserForm 2
Easiest is to leave it there and use the queryclose event to manage closing
the form. See Stephen Bullens site for API related material You can look at his formfun.zip (uncompress to an excel file) that shows you all the things you can do with a userform - code is accessible http://www.bmsltd.ie/Excel/Default.htm -- Regards, Tom Ogilvy "Tim" wrote in message ... Hello, Is there a way to eliminate the close button [X] at the top right of the userform? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
UserForm 2
Tim,
You can manage it rather than eliminate it. There is a QueryClose event that is invoked whenever the form is unloaded. There are 4 close circumstances, so you can trap them and react as you see fit. Here is some code Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) Select Case CloseMode Case vbFormControlMenu: Cancel = True 'User has chosen the Close command from the 'Control menu on the UserForm. Case vbFormCode: 'Unload statement invoked from code. Case vbAppWindows: 'Current Windows session is ending. Case vbAppTaskManager: 'Windows Task Manager is closing the application End Select End Sub In this I have shown all 4 instances, but the only one that is actioned is the Control Menu close, the X that is, where I cancel the close. So it has no effect when clicking the X. You could action some of the others, but be careful, you might never be able to close the dang thing. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Tim" wrote in message ... Hello, Is there a way to eliminate the close button [X] at the top right of the userform? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
UserForm 2
Hi Tim,
Try this, Put below code in userform's code module. Should work in XL-97 & onwards. 'Original Code by Stephen Bullens & modified 'Show Userform without X Button (System Menu). Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long Private Const GWL_STYLE As Long = -16 Private Const WS_SYSMENU As Long = &H80000 Dim hWndForm, iStyle As Long Private Sub UserForm_Activate() hWndForm = FindWindow(vbNullString, Me.Caption) iStyle = GetWindowLong(hWndForm, GWL_STYLE) iStyle = iStyle And Not WS_SYSMENU SetWindowLong hWndForm, GWL_STYLE, iStyle DrawMenuBar hWndForm End Sub Regards, Shah Shailesh http://members.lycos.co.uk/shahweb/ *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA userform | Excel Worksheet Functions | |||
UserForm | Excel Discussion (Misc queries) | |||
Userform Help in VBC | Excel Discussion (Misc queries) | |||
Userform | Excel Programming | |||
userform | Excel Programming |