Home Page
M S Excel User Form title bar close icon is the main facts to need the title bar hide. When you run the VBA in visual studio then title bar is open and close icon works is that to close the user form but not the active workbook, when you click the close icon the user form is close but work book and work sheet is not close , again when you open the user form then show the error, solving this error to need the hide title bar of user form and make its own command button to close the user form and work sheet also.
It is two part to write the code
1. Scripting codes
2. User Form ittlizied module
1. Scripting codes:-
Start scripting codes in user form top
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)
Close module
2. Open User Form ittlizied module:-
when you write the scripting module then you write the ittlizied module.
Start module
Dim frm As Long
Dim wHandle As Long
wHandle = FindWindow(vbNullString, Me.Caption)
frm = GetWindowLong(wHandle, GWL_STYLE)
SetWindowLong wHandle, -16, 0
DrawMenuBar wHandle
Close module
Some other topics:-
1. TextBox change Module
2. Who to Solved Script Error in MS Excel
3. Use Vlookup Formula in MS Excel UserForm TextBox
4. Who to Lock your MS Excel File
5. MS Excel UserForm Save And Edit Module Part-1
6. MS Excel UserForm Save And Edit Module Part-2
7. TextBox Enter module.