Hello maacmaac,
Here is th macro code. Place this in a standard VBA module. You need to call this macro from the UserForm_Activate event module. You should add a fail safe way to close the UserForm, if you code fails to close it. I have an example at the bottom.
'Written: August 01, 2009
'Author: Leith Ross
'Summary: Removes the Titlebar and thick border around a UserForm.
'Returns the Window Handle of the Window that is accepting User input.
Public Declare Function GetForegroundWindow Lib "user32.dll" () As Long
Private Declare Function GetWindowLong _
Lib "user32.dll" _
Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong _
Lib "user32.dll" _
Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Sub RemoveFrame()
Dim Bitmask As Long
Dim hWnd As Long
Dim WindowStyle As Long
Const GWL_STYLE As Long = (-16)
Const WS_DLGFRAME As Long = &H400000
hWnd = GetForegroundWindow
WindowStyle = GetWindowLong(hWnd, GWL_STYLE)
Bitmask = WindowStyle And (Not WS_DLGFRAME)
Call SetWindowLong(hWnd, GWL_STYLE, Bitmask)
End Sub
UserForm Code
Private Sub UserForm_Activate()
RemoveFrame
End Sub
Fail Safe to Close UserForm
Private Sub UserForm_Click()
Unload Me
End Sub
Bookmarks