ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Cell Menu (https://www.excelbanter.com/excel-discussion-misc-queries/3880-cell-menu.html)

GregR

Cell Menu
 
I have the following code which adds the macros to the cell menu. How do I
begin a group for the array or assign the array to a submenu. TIA

Greg



GregR

Might be nice if I added the code:
Sub AddtoCellMenuAbs()

Dim iCtr As Long
Dim myMacros As Variant
Dim myCaptions As Variant

Dim cb As CommandBar
Set cb = Application.CommandBars("Cell")

myMacros = Array("Absolute.Absolute", "Relative", "AbsoluteRow",
"AbsoluteCol")
myCaptions = Array("Absolute", "Relative", "Absolute Row", "Absolute
Col")

With cb.Controls

For iCtr = LBound(myMacros) To UBound(myMacros)
With .Add(Type:=msoControlButton, temporary:=True)
.Caption = myCaptions(iCtr)
.OnAction = ThisWorkbook.Name & "!" & myMacros(iCtr)
' .FaceId = 103
' .BeginGroup = True
End With
Next iCtr
End With
'in your workbook_open/auto_open code, you can just have a
'Call AddToCellMenu
End Sub

Greg
"GregR" wrote in message
...
I have the following code which adds the macros to the cell menu. How do I
begin a group for the array or assign the array to a submenu. TIA

Greg





Norman Jones

Hi GregR,

One way:

Sub AddtoCellMenuAbs()

Dim iCtr As Long
Dim myMacros As Variant
Dim myCaptions As Variant
Dim blBeginGroup As Boolean

Dim cb As CommandBar
Set cb = Application.CommandBars("Cell")

myMacros = Array("Absolute.Absolute", "Relative", _
"AbsoluteRow", "AbsoluteCol")
myCaptions = Array("Absolute", "Relative", _
"Absolute Row", "AbsoluteCol ")

With cb.Controls
For iCtr = LBound(myMacros) To UBound(myMacros)
With .Add(Type:=msoControlButton, temporary:=True)
.Caption = myCaptions(iCtr)
.OnAction = ThisWorkbook.Name & "!" & myMacros(iCtr)
.FaceId = 103
If Not blBeginGroup Then
.BeginGroup = True
blBeginGroup = True
End If
End With
Next iCtr
End With
'in your workbook_open/auto_open code, you can just have a
'Call AddToCellMenu
End Sub


---
Regards,
Norman



"GregR" wrote in message
...
Might be nice if I added the code:
Sub AddtoCellMenuAbs()

Dim iCtr As Long
Dim myMacros As Variant
Dim myCaptions As Variant

Dim cb As CommandBar
Set cb = Application.CommandBars("Cell")

myMacros = Array("Absolute.Absolute", "Relative", "AbsoluteRow",
"AbsoluteCol")
myCaptions = Array("Absolute", "Relative", "Absolute Row", "Absolute
Col")

With cb.Controls

For iCtr = LBound(myMacros) To UBound(myMacros)
With .Add(Type:=msoControlButton, temporary:=True)
.Caption = myCaptions(iCtr)
.OnAction = ThisWorkbook.Name & "!" & myMacros(iCtr)
' .FaceId = 103
' .BeginGroup = True
End With
Next iCtr
End With
'in your workbook_open/auto_open code, you can just have a
'Call AddToCellMenu
End Sub

Greg
"GregR" wrote in message
...
I have the following code which adds the macros to the cell menu. How do
I
begin a group for the array or assign the array to a submenu. TIA

Greg







GregR

Norman, thank you very much.

Greg
"Norman Jones" wrote in message
...
Hi GregR,

One way:

Sub AddtoCellMenuAbs()

Dim iCtr As Long
Dim myMacros As Variant
Dim myCaptions As Variant
Dim blBeginGroup As Boolean

Dim cb As CommandBar
Set cb = Application.CommandBars("Cell")

myMacros = Array("Absolute.Absolute", "Relative", _
"AbsoluteRow", "AbsoluteCol")
myCaptions = Array("Absolute", "Relative", _
"Absolute Row", "AbsoluteCol ")

With cb.Controls
For iCtr = LBound(myMacros) To UBound(myMacros)
With .Add(Type:=msoControlButton, temporary:=True)
.Caption = myCaptions(iCtr)
.OnAction = ThisWorkbook.Name & "!" & myMacros(iCtr)
.FaceId = 103
If Not blBeginGroup Then
.BeginGroup = True
blBeginGroup = True
End If
End With
Next iCtr
End With
'in your workbook_open/auto_open code, you can just have a
'Call AddToCellMenu
End Sub


---
Regards,
Norman



"GregR" wrote in message
...
Might be nice if I added the code:
Sub AddtoCellMenuAbs()

Dim iCtr As Long
Dim myMacros As Variant
Dim myCaptions As Variant

Dim cb As CommandBar
Set cb = Application.CommandBars("Cell")

myMacros = Array("Absolute.Absolute", "Relative", "AbsoluteRow",
"AbsoluteCol")
myCaptions = Array("Absolute", "Relative", "Absolute Row", "Absolute
Col")

With cb.Controls

For iCtr = LBound(myMacros) To UBound(myMacros)
With .Add(Type:=msoControlButton, temporary:=True)
.Caption = myCaptions(iCtr)
.OnAction = ThisWorkbook.Name & "!" & myMacros(iCtr)
' .FaceId = 103
' .BeginGroup = True
End With
Next iCtr
End With
'in your workbook_open/auto_open code, you can just have a
'Call AddToCellMenu
End Sub

Greg
"GregR" wrote in message
...
I have the following code which adds the macros to the cell menu. How

do
I
begin a group for the array or assign the array to a submenu. TIA

Greg










All times are GMT +1. The time now is 06:43 AM.

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