VBA - Userform as Menu Bar

Sinbad

Board Regular
Joined
Apr 18, 2012
Messages
224
Hi all,

I want to use a Userform with a bunch of buttons on it as a sticky Menu bar..

What i mean is that this form should be displayed always in the top center of the screen and only show the buttons, no Titlebar, frame etc... just the buttons.

I have the bar made up, created all the buttons and can show the form. Problem is it has the Title and a lovely fat frame around it.

So how can i get only the buttons as tight as can be.. button dimensions are W48 and the important one.. Height is 18

Any suggestions ?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
found how to remove the title bar.. still got lots of space around the buttons though. i drag the form itself to be smaller than the actual buttons are, but still have space below the buttons.

this is what i found.
Code:
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 RemoveCaption(objForm As Object)

Dim lStyle          As Long
Dim hMenu           As Long
Dim mhWndForm       As Long

    If Val(Application.Version) < 9 Then
        mhWndForm = FindWindow("ThunderXFrame", objForm.Caption)    'XL97
    Else
        mhWndForm = FindWindow("ThunderDFrame", objForm.Caption)    'XL2000+
    End If
    lStyle = GetWindowLong(mhWndForm, -16)
    lStyle = lStyle And Not &HC00000
    SetWindowLong mhWndForm, -16, lStyle
    DrawMenuBar mhWndForm

End Sub

Sub ShowForm()

    UserForm1.Show False
    UserForm3.Show False

End Sub
 
Upvote 0
next problem I am notecing is that i can not actually work in Excel when the Form is up. any way to have the form show and still be able to work in Excel ?

Sorted.. need to change the form properties --> Show Modal to false..
 
Last edited:
Upvote 0

Forum statistics

Threads
1,203,064
Messages
6,053,320
Members
444,653
Latest member
Curdood

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top