0% found this document useful (0 votes)
2 views2 pages

Remove Title Bar in VBA UserForms

The document contains VBA code for a function that removes the title bar from a user form in Microsoft Office applications. It uses Windows API functions to manipulate window styles and redraw the menu bar. The code includes a subroutine to display the user form without the title bar.

Uploaded by

mego.ud07
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Remove Title Bar in VBA UserForms

The document contains VBA code for a function that removes the title bar from a user form in Microsoft Office applications. It uses Windows API functions to manipulate window styles and redraw the menu bar. The code includes a subroutine to display the user form without the title bar.

Uploaded by

mego.ud07
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Option Explicit

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

Sub RemoveTitleBar(frm As Object)

Dim lStyle As Long

Dim hMenu As Long

Dim mhWndForm As Long

If Val([Link]) < 9 Then

mhWndForm = FindWindow("ThunderXFrame", [Link]) 'for Office 97 version

Else

mhWndForm = FindWindow("ThunderDFrame", [Link]) 'for office 2000 or above


End If

lStyle = GetWindowLong(mhWndForm, -16)

lStyle = lStyle And Not &HC00000

SetWindowLong mhWndForm, -16, lStyle

DrawMenuBar mhWndForm

End Sub

Sub ShowForm()

[Link] False

End Sub

You might also like