ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Custom Command Bars (https://www.excelbanter.com/excel-programming/437908-custom-command-bars.html)

Barb Reinhardt

Custom Command Bars
 
I've figured out a way to add custom commands to the ROWS or CELLS
commandbars, but I only seem to be able to add one. Can someone help me
figure out how to add multiple custom commands to one of those command bars?

Thanks,

Barb Reinhardt


michdenis

Custom Command Bars
 
Hi,

Copie this in a general module

It's working in Excel 2003 and Excel 2007

'-----------------------------
Sub test()
Dim MBar As CommandBar

Set MBar = Application.CommandBars("Column")
'OR
'Set MBar = Application.CommandBars("Row")
With MBar
With .Controls.Add
.BeginGroup = True
.Caption = "NewCommand1"
.OnAction = "Happy_New_Year"
End With
With .Controls.Add
.Caption = "NewCommand2"
.OnAction = "OK"
End With
End With

End Sub
'-----------------------------
Sub Ok()
MsgBox "Is it working ?"
End Sub
'-----------------------------
Sub Happy_New_Year()
MsgBox "you too"
End Sub
'-----------------------------



"Barb Reinhardt" a écrit dans le message de
groupe de discussion : ...
I've figured out a way to add custom commands to the ROWS or CELLS
commandbars, but I only seem to be able to add one. Can someone help me
figure out how to add multiple custom commands to one of those command bars?

Thanks,

Barb Reinhardt



All times are GMT +1. The time now is 04:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com