PC Review


Reply
Thread Tools Rate Thread

CommandBar and Controls (how to create separate "Sets" of Controls)

 
 
EagleOne@discussions.microsoft.com
Guest
Posts: n/a
 
      26th Mar 2010
Excel 2003 & 2007 up to date


The code below was obtained from vbaexpress as noted. I modified it for my specifics.

For hours, I attempted to create a distinct Command Bar Menu "Set" of controls to no avail.

In short, my Add-Ins Tab in 2007 has two sections in the Menubar: ""Menu Commands" (which contains
5 dropdrown controls) and "Custom Toolbars" (which contains 3 .pdf controls). I would like my
menu item "&VBA Setup" to be in a separate section like ""Menu Commands" and "Custom Toolbars"
Thus 3 SECTIONS i.e. "Custom Toolbars;" "Custom Toolbars;" and "VBATools"

What code lines am I missing?

Any thoughts greatly appreciated.

***********************************************************************************************
CODE NEXT
***********************************************************************************************

Private Sub Workbook_Open()
' http://www.vbaexpress.com/kb/getarti...b_id=427#instr
' 3/22/2010

Dim cmbBar As CommandBar
Dim cmbControl As CommandBarControl

Set cmbBar = Application.CommandBars("Worksheet Menu Bar")

If cmbBar.Controls(cmbBar.Controls.count).Caption <> "" Then
Set cmbControl = cmbBar.Controls.Add(Type:=msoControlButton, Temporary:=True)
End If
Set cmbControl = cmbBar.Controls.Add(Type:=msoControlPopup, Temporary:=True) 'adds a menu item
With cmbControl
.Caption = "&VBA Setup" 'names the menu item
With .Controls.Add(Type:=msoControlButton) 'adds a dropdown button to the menu item
.Caption = "Add-Ins Install" 'adds a description to the menu item
.OnAction = "ToolsInitDLL.AddinsInstall" 'runs the specified macro
.FaceId = 220 'assigns an icon to the dropdown
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Add-Ins Un-Install"
.OnAction = "ToolsInitDLL.AddInsUninstall"
.FaceId = 220
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Apply Macro Shortcuts"
.OnAction = "ToolsInitDLL.ApplyShortCuts"
.FaceId = 220
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "VB Library References"
.OnAction = "ToolsInitDLL.ListObjLibReferences"
.FaceId = 220
End With
End With
End Sub
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      26th Mar 2010
You have no control over those groups, Excel 2007 maintains the two groups
and puts commandbars into them depending upon whether it is menus or
toolbars (in Excel 2003 speak). If you wan to control it, you have to create
your own ribbon elements.

--

HTH

Bob

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Excel 2003 & 2007 up to date
>
>
> The code below was obtained from vbaexpress as noted. I modified it for
> my specifics.
>
> For hours, I attempted to create a distinct Command Bar Menu "Set" of
> controls to no avail.
>
> In short, my Add-Ins Tab in 2007 has two sections in the Menubar: ""Menu
> Commands" (which contains
> 5 dropdrown controls) and "Custom Toolbars" (which contains 3 .pdf
> controls). I would like my
> menu item "&VBA Setup" to be in a separate section like ""Menu
> Commands" and "Custom Toolbars"
> Thus 3 SECTIONS i.e. "Custom Toolbars;" "Custom Toolbars;" and
> "VBATools"
>
> What code lines am I missing?
>
> Any thoughts greatly appreciated.
>
> ***********************************************************************************************
> CODE NEXT
> ***********************************************************************************************
>
> Private Sub Workbook_Open()
> ' http://www.vbaexpress.com/kb/getarti...b_id=427#instr
> ' 3/22/2010
>
> Dim cmbBar As CommandBar
> Dim cmbControl As CommandBarControl
>
> Set cmbBar = Application.CommandBars("Worksheet Menu Bar")
>
> If cmbBar.Controls(cmbBar.Controls.count).Caption <> "" Then
> Set cmbControl = cmbBar.Controls.Add(Type:=msoControlButton,
> Temporary:=True)
> End If
> Set cmbControl = cmbBar.Controls.Add(Type:=msoControlPopup,
> Temporary:=True) 'adds a menu item
> With cmbControl
> .Caption = "&VBA Setup" 'names the menu item
> With .Controls.Add(Type:=msoControlButton) 'adds a dropdown button
> to the menu item
> .Caption = "Add-Ins Install" 'adds a description to the menu
> item
> .OnAction = "ToolsInitDLL.AddinsInstall" 'runs the specified
> macro
> .FaceId = 220 'assigns an icon to the dropdown
> End With
> With .Controls.Add(Type:=msoControlButton)
> .Caption = "Add-Ins Un-Install"
> .OnAction = "ToolsInitDLL.AddInsUninstall"
> .FaceId = 220
> End With
> With .Controls.Add(Type:=msoControlButton)
> .Caption = "Apply Macro Shortcuts"
> .OnAction = "ToolsInitDLL.ApplyShortCuts"
> .FaceId = 220
> End With
> With .Controls.Add(Type:=msoControlButton)
> .Caption = "VB Library References"
> .OnAction = "ToolsInitDLL.ListObjLibReferences"
> .FaceId = 220
> End With
> End With
> End Sub



 
Reply With Quote
 
EagleOne@discussions.microsoft.com
Guest
Posts: n/a
 
      26th Mar 2010
Hello Bob!

Thanks. That is why it was not working!

What code would I need to force-place menu item (dropdown) "&VBA Setup"
at the Top of a "visible-column" in the group "Menu Commands." Currently the display shows the
"column" in groups of three (I realize that depends on HxW settings). My code does insert a "blank"
before "&VBA Setup" to provide some visual separation.

Appreciate your help! Bob.

"Bob Phillips" <(E-Mail Removed)> wrote:

>You have no control over those groups, Excel 2007 maintains the two groups
>and puts commandbars into them depending upon whether it is menus or
>toolbars (in Excel 2003 speak). If you wan to control it, you have to create
>your own ribbon elements.

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      26th Mar 2010
As I said, you have no control, Excel decides that, presumably on the order
that the files are loaded.

--

HTH

Bob

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello Bob!
>
> Thanks. That is why it was not working!
>
> What code would I need to force-place menu item (dropdown) "&VBA Setup"
> at the Top of a "visible-column" in the group "Menu Commands." Currently
> the display shows the
> "column" in groups of three (I realize that depends on HxW settings). My
> code does insert a "blank"
> before "&VBA Setup" to provide some visual separation.
>
> Appreciate your help! Bob.
>
> "Bob Phillips" <(E-Mail Removed)> wrote:
>
>>You have no control over those groups, Excel 2007 maintains the two groups
>>and puts commandbars into them depending upon whether it is menus or
>>toolbars (in Excel 2003 speak). If you wan to control it, you have to
>>create
>>your own ribbon elements.



 
Reply With Quote
 
EagleOne@discussions.microsoft.com
Guest
Posts: n/a
 
      26th Mar 2010
Oh well! Thanks Bob

"Bob Phillips" <(E-Mail Removed)> wrote:

>As I said, you have no control, Excel decides that, presumably on the order
>that the files are loaded.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Controls tab missing from "Format Controls" for Option Button Marc Hillman Microsoft Excel Discussion 3 22nd Jun 2008 03:44 PM
Seens there are "standard Microsoft Windows controls" and "common controls" Academia Microsoft VC .NET 4 18th Jan 2008 01:13 AM
Deleting CommandBar("").Controls itsthedude@gmail.com Microsoft Excel Programming 3 9th Jan 2008 02:20 AM
Q: "Grouping" controls / "locking" controls to background? StargateFan Microsoft Access 3 17th Dec 2005 02:58 AM
can you create one "MouseEnter" event handler for multiple controls on a form? JohnR Microsoft VB .NET 3 27th Jun 2005 07:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:02 PM.