|
-
Jun 8th, 2006, 01:07 AM
#1
Thread Starter
Member
Captionless MSO CommandBar !!
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:
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
Is there a special Style for these type of MSO CommandBars class ? ? Or maybe a SendMessage Function is needed with a special Msg ??
This is driving me mad and any help would be much appreciated .
-
Jun 8th, 2006, 05:42 AM
#2
Re: Captionless MSO CommandBar !!
As far as I know you can't because the caption appears to be the name of the bar, and therefore is used in the indexing/collection.
You can create a toolbar with a space as the name.. would this help?
Otherwise try to make the toolbar always start off attached to the menus at the top - no title is then displayed.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jun 8th, 2006, 06:03 AM
#3
Re: Captionless MSO CommandBar !!
Why not use the Office Object Model to access the toolbar and remove the caption from the button(s)?
There is no Caption property for a Toolbar but there is for a ToolbarButton.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 8th, 2006, 08:46 AM
#4
Thread Starter
Member
Re: Captionless MSO CommandBar !!
Thanks guys but this Toolbar is meant to be dynamically attached to an Excel userform at run time that's why docking it at the top of the application window as suggested is not an answer.
If I manage to get rid of the tollbar title bar, the toolbar buttons would look as if they were floating on top of the userform which is the visual effect I want.
I am really desperate to make this work even if I have to create the toolbar from scrach using the API but I don't know how
Adding button controls to the userform and copying FaceIds pictures to them as well as arranging them next to each other accross the top of the UserForm would still not be as good as having the real thing .
Anyone knows how I can create an MSO Toolbar from scrach using the API so I can freely manipulate it and set its Caption\Title bar Window Styles among other things ??
Anyone ? Thanks.
-
Jun 8th, 2006, 08:49 AM
#5
Re: Captionless MSO CommandBar !!
Your loosing me. You want a userform without a Titlebar but with a commandbar toolbar? Can you sketch a crude drawing?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 8th, 2006, 09:46 AM
#6
Thread Starter
Member
Re: Captionless MSO CommandBar !!
Sorry for not explaining properly.
I want to keep the UserForm Title Bar as normal but I also want to attach a Captionless Toolbar accross the top of the UserForm (ie : Just under the UserForm Title Bar).
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|