​A selection of topics on IT and its application to finance. 
​Send me your comments, questions ​or suggestions by clicking

Removing the title bar from an EXCEL 97 or 2000 VBA userform 

To remove the title bar from a vba userform we need to use the win API so please make sure you're comfortable with this before continuing. It's not difficult and you can have a look at my other article here for more information.

So, first create a new form, userform2 say, and put the following in the general declaration section:

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 Const GWL_STYLE As Long = (-16)           'The offset of a window's style
Private Const WS_CAPTION As Long = &HC00000       'Style to add a titlebar

Next in the initialize section all you need is the following code:

hwndform = FindWindow("ThunderXframe", UserForm2.Caption)

istyle = GetWindowLong(hwndform, GWL_STYLE)
istyle = istyle And Not WS_CAPTION
X = SetWindowLong(hwndform, GWL_STYLE, istyle)
DrawMenuBar hwndform

'ThunderXframe' in the FindWindow call above refers to the code name that microsoft developers had for EXCEL 97. For EXCEL 2000 applications you should use 'ThunderDframe'. No doubt othe versions of EXCEL will have their own codes too, look 'em up on google if you need them.