Custom toolbar macro

JimM

Well-known Member
Joined
Nov 11, 2003
Messages
752
Hi all

I've pinched some code from a previous thread which creates a custom toolbar when I open a workbook

It works OK but I would like to tweak a couple of things, so any idea on how I do the following

1. At present the tool bar opens in the middle of the worksheet, how do I get it to 'dock' in the toolbar area at the top of the screen

2. To run the macro that's inside the toolbar I have to click on the tool bar to activate a dropdown list and then click the (only) button. How can I get the button moved up a level so that it's directly accessible from the toolbar (ie I don't have to to do the dropdown bit)

Thanks

Jim



Private Sub CreateMyCommandBar()
Dim ocb As CommandBarControl
Dim cbr As CommandBar
Dim objCommandBarButton As CommandBarButton
'reset/delete a previous custom menu before create a new custom menu
Call DeleteMyCommandBar
Set cbr = Application.CommandBars.Add("MyMenu")
Set ocb = cbr.Controls.Add(Type:=msoControlPopup, Temporary:=True)
ocb.Caption = "&My Menu"
'add a ControlButton to a commandbar

Set objCommandBarButton = ocb.Controls.Add(Type:=msoControlButton, ID:=1)
With objCommandBarButton
.Caption = "MyMenu"
.OnAction = "tabmenu"
.Style = msoButtonIconAndCaption
.FaceId = 2892
.BeginGroup = False
End With

Set ocb = Nothing
Set objCommandBarButton = Nothing
Application.CommandBars("MyMenu").Visible = True

End Sub
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Thanks Sektor, that's got the first one sorted

Has anyone any ideas on number 2 !

Cheers

Jim
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,710
Members
452,939
Latest member
WCrawford

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