Thread: UserForm 2
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Shailesh Shah[_2_] Shailesh Shah[_2_] is offline
external usenet poster
 
Posts: 114
Default 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!