我的代码创建菜单,在命令栏中添加按钮,从excel文件中获取用户填充的值。由于菜单项的数量不是固定的,因此菜单是通过循环创建的。在行动上,我想转到excel文件中的命名范围。无法做到这一点。请帮助。
Dim myCB As CommandBar
Set myCPup = myCB.Controls.Add(Type:=msoControlPopup)
For counter = 1 To Main_menu_items_count
Set myCPBtn = myCPup.Controls.Add(Type:=msoControlButton)
gorange = Application.WorksheetFunction.Substitute(myrange(counter, 1), " ", "") & "_Home"
With myCPBtn
.Style = msoButtonAutomatic
.Caption = myrange(counter, 1)
On Error Resume Next
.OnAction = Application.Goto(gorange)
End With
Next