mmn1000
Board Regular
- Joined
- Mar 17, 2020
- Messages
- 90
- Office Version
- 2019
- 2013
- Platform
- Windows
Hi
I deleted the userform title bar in an Excel file using code
I need help to moving the userform
I want to be able to move the userform by clicking and holding it
I deleted the userform title bar in an Excel file using code
I need help to moving the userform
I want to be able to move the userform by clicking and holding it
VBA Code:
Option Explicit
Option Private Module
Public Const GWL_STYLE = -16
Public Const WS_CAPTION = &HC00000
Public Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Public Declare PtrSafe Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Sub HideTitleBar(frm As Object)
Dim lngWindow As Long
Dim lFrmHdl As Long
lFrmHdl = FindWindowA(vbNullString, frm.Caption)
lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE)
lngWindow = lngWindow And (Not WS_CAPTION)
Call SetWindowLong(lFrmHdl, GWL_STYLE, lngWindow)
Call DrawMenuBar(lFrmHdl)
End Sub
VBA Code:
Private Sub UserForm_Initialize()
Call RemoveTitleBar(Me)
End Sub