How do I strip (remove) the caption of a custom CommandBar in EXCEL ?
I know how to do that for userforms as well as other windows via setting the window Styles but can't make it work for commandbars.
Here is what I have so far but it doesn't work !![]()
"Test" is the Caption of the EXCEL Custom Toolbar which is on display when the Code runs.
Code in a Bas Module:
Is there a special Style for these type of MSO CommandBars class ? ? Or maybe a SendMessage Function is needed with a special Msg ??VB Code:
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 Dim lngCBHwnd As Long Dim IStyle Sub Test() lngCBHwnd = FindWindow("MsoCommandBar", "Test") Debug.Print lngCBHwnd IStyle = GetWindowLong(lngCBHwnd, GWL_STYLE) IStyle = IStyle And Not WS_CAPTION SetWindowLong lngCBHwnd, GWL_STYLE, IStyle DrawMenuBar lngCBHwnd End Sub
This is driving me mad and any help would be much appreciated .




Reply With Quote