Adding "Add-Ins..." control to custom tooolbar

S

Sandusky

Windows XP Pro SP2
Excel 2002 SP3

I have an AddIn that I created that creates a toolbar when the AddIn is
turned on, and I want to add the "Add-Ins..." control from the Tools menu to
this custom toolbar. I know I can get to the "Add-Ins..." control by

Dim MyCtrl as CommandBarsControl
Set MyCtrl = Application.CommandBars("Tools").Controls(15)

The problem arises when I try to copy to my custom toolbar (named
"MyToolbar") as I REALLY want to copy MyCtrl to a CommandBarPopup that is on
"MyToolbar".

So this is what I have

MyCtrl, the "Add-Ins..." control from the Tools menu
MyToolbar, created programmatically
MyMenu, a CommandBarPopup on MyToolbar

Any ideas?

Thanks!!

-gk-
 
J

Jim Cone

gk,
You can use the "Copy" method to copy an existing control to a toolbar...

Sub PutHerThere()
Dim MyCtrl As CommandBarControl
Dim MyToolbar As CommandBar
Set MyCtrl = Application.CommandBars.FindControl(ID:=943) 'Add-Ins control
Set MyToolbar = Application.CommandBars.Add("TempBar", msoBarFloating, False, True)

MyCtrl.Copy bar:=MyToolbar
MyToolbar.Visible = True

Set MyCtrl = Nothing
Set MyToolbar = Nothing
End Sub

'Get rid of it...
Sub Goodbye()
Application.CommandBars("TempBar").Delete
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"Sandusky"
wrote in message
Windows XP Pro SP2
Excel 2002 SP3
I have an AddIn that I created that creates a toolbar when the AddIn is
turned on, and I want to add the "Add-Ins..." control from the Tools menu to
this custom toolbar. I know I can get to the "Add-Ins..." control by

Dim MyCtrl as CommandBarsControl
Set MyCtrl = Application.CommandBars("Tools").Controls(15)

The problem arises when I try to copy to my custom toolbar (named
"MyToolbar") as I REALLY want to copy MyCtrl to a CommandBarPopup that is on
"MyToolbar".
So this is what I have

MyCtrl, the "Add-Ins..." control from the Tools menu
MyToolbar, created programmatically
MyMenu, a CommandBarPopup on MyToolbar

Any ideas?
Thanks!!
-gk-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top