Problem with tool bar created with VBA

Skip Bisconer

Active Member
Joined
Jun 14, 2002
Messages
263
I have set up a utility tool bar that opens with a particular workbook and goes away when that workbook closes. It has been working great for me for a long time with two buttons running macros correctly. I wanted to add another button to run an additional macro to the tool bar but the new button in the below code replaces the second button instead of adding to the toolbar. It must be in the code I have written but I can't figure what is wrong. I appreciate you looking at my problem.

Private Sub Workbook_Open()
On Error Resume Next


Application.CommandBars("MSN Money Stock Quotes").Visible = True

'Macro recorded 6/28/2004 by Milo E Bisconer
'Create a toolbar and add a button with a particular face ID
'to run a macro.
On Error Resume Next




Dim Tbar As CommandBar
Dim NewBtn

Set Tbar = Application.CommandBars.Add
With Tbar
.Name = "Utilities"
.Top = 60
.Left = 1120


.Visible = True
End With

' Use JWalker FaceID Addin

Set NewBtn = Tbar.Controls.Add _
(Type:=msoControlButton)

With NewBtn
.FaceId = 643
.OnAction = "CopyQuickenLastPriceData" 'Run a macro
.Caption = "Quicken Last Price Update" 'Tool tip

End With

Set NewBtn = Tbar.Controls.Add _
(Type:=msoControlButton)

With NewBtn
.FaceId = 1378
.OnAction = "ChangeGainLossMeasure"
.Caption = "Delete Gain Loss measure for new update"
End With

With NewBtn
.FaceId = 25
.OnAction = "OpenfrmProfile"
.Caption = "View Company Profiles"

End With

End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Skip Bisconer

Active Member
Joined
Jun 14, 2002
Messages
263
Sorry to have wasted your time I found my problem after I posted this.
I forgot to do a new Set NewBtn = Tbar.Controls.Add _
(Type:=msoControlButton) for the new button.

Thanks for looking anyway.
 

Forum statistics

Threads
1,144,625
Messages
5,725,365
Members
422,621
Latest member
dfrare

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
Top