Les 20:56 05 Mar 2003

Could you help me please.

Many yars ago I used to program in VB2 and, if I wanted a form I could get it without the bar at the top - is this possible in VBA?

  VoG™ 22:45 05 Mar 2003

Yes it is

The first step is to create a class module. Name the class module "cTitleBarHider" and put the following code in it:

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)

Private Const WS_CAPTION As Long = &HC00000

Public Property Set Form(oForm As Object)

Dim iStyle As Long

Dim hWndForm As Long

If Val(Application.Version) < 9 Then


hWndForm = FindWindow("ThunderXFrame", oForm.Caption)



hWndForm = FindWindow("ThunderDFrame", oForm.Caption)

End If

iStyle = GetWindowLong(hWndForm, GWL_STYLE)

iStyle = iStyle And Not WS_CAPTION

SetWindowLong hWndForm, GWL_STYLE, iStyle

DrawMenuBar hWndForm

End Property

Then, in the code module of any userform you wish to be titleless, put the following code:

Dim oTitleBarHider As New cTitleBarHider

Private Sub UserForm_Activate()

Set oTitleBarHider.Form = Me

End Sub

Lastly, change the userform's border style property to 1-fmBorderStyleSingle in the userform's property box. This will improve the appearance of the userform when it is displayed.

When the form is displayed, the UserForm_Activate procedure will run and in turn run the code in the class module which hides the title bar.


The above is taken from Visual Basic Macro Examples from click here

I should add (1) I have not tried this myself and (2) anybody interested in VB programming in Excel - beginner or expert - would be well advised to get this plus click here

Finally it is very flattering that you have called me up by name but there are other Excel people on here like Whisperer and Cherria to name only two.

  Les 23:27 05 Mar 2003

VoG™ - such is the price of fame :-)) When I had this problem your name immediately sprang to mind
- so many times have I seen your non-de-plume answering queries on VBA! Many thanks for the links and solution.

To Whisperer, Cherria (and anyone else) I apologise - no slight intended - your help is always appreciated

  Les 17:50 12 Mar 2003

I have tried the code you so kindly posted for me - it did work and solved the problem I had. Again, many thanks.

  VoG™ 18:27 12 Mar 2003

Glad to hear it worked.

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

OnePlus 5T review: Hands-on

Illustrator Andrés Lozano on his improv line work, brazen use of colours & hand sketching

iPhone X review

Comment envoyer gratuitement des gros fichiers ?