Browse » Home
Monday, May 23, 2011
How to Remove the Blue Titlebar From UserForm in Excel 2003
1. Launch Microsoft Excel 2003. Press the “Alt” and “F11” keys on your computer keyboard at the same time to launch the Microsoft Visual Basic Editor application inside Excel.
2. Click “Insert” in the main navigation menu. Select “UserForm” from the drop-down menu.
3. Double-click the “UserForm1” window to open the code window. Highlight and delete any code in the window.
4. Paste the following code into the window:Option ExplicitPrivate Sub UserForm_Initialize()Call RemoveCaption(Me)End Sub
5. Click “Insert” in the main navigation menu. Select “Module” from the drop-down menu.
6. Paste the following code into the Module window:Option ExplicitPrivate Declare Function FindWindow Lib 'User32' _
Alias 'FindWindowA' ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As LongPrivate Declare Function GetWindowLong Lib 'User32' _
Alias 'GetWindowLongA' ( _
ByVal hwnd As Long, _
ByVal nIndex As Long) As LongPrivate Declare Function SetWindowLong Lib 'User32' _
Alias 'SetWindowLongA' (ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As LongPrivate Declare Function DrawMenuBar Lib 'User32' ( _
ByVal hwnd As Long) As LongSub RemoveCaption(objForm As Object)Dim lStyle As Long
Dim hMenu As Long
Dim mhWndForm As LongIf Val(Application.Version)
mhWndForm = FindWindow('ThunderXFrame', objForm.Caption) 'XL97
Else
mhWndForm = FindWindow('ThunderDFrame', objForm.Caption) 'XL2000
End If
lStyle = GetWindowLong(mhWndForm, -16)
lStyle = lStyle And Not HC00000
SetWindowLong mhWndForm, -16, lStyle
DrawMenuBar mhWndFormEnd SubSub ShowForm()UserForm1.Show FalseEnd Sub
7. Click the “x” button in the top right-hand corner of the Visual Basic Editor window to close the application and all windows. You don’t need to save the contents of the code boxes.
8. Click “Tools” in the main menu. Select “Macro” followed by “Macros.” Select “ShowForm.” Click the “Run” button. The Excel user form now displays without the title bar.