Crear Mi menu
Buenas noches
Encontre esta Macro para crear mi menu
Sub CreateMenu()
Dim cbMenu As CommandBarControl, cbSubMenu As CommandBarControl
Set cbMenu = Application.CommandBars(1).Controls.Add(msoControlPopup, , , , True)
With cbMenu
.Caption = "&Mi menu"
.Tag = "MyTag"
.BeginGroup = False
End With
If cbMenu Is Nothing Then Exit Sub
With cbMenu.Controls.Add(msoControlButton, 1, , , True)
.Caption = "&Menu Item1"
.OnAction = ThisWorkbook.Name & "!Macroname"
End With
With cbMenu.Controls.Add(msoControlButton, 1, , , True)
.Caption = "&Menu Item2"
.OnAction = ThisWorkbook.Name & "!Macroname"
End With
Set cbSubMenu = cbMenu.Controls.Add(msoControlPopup, 1, , , True)
With cbSubMenu
.Caption = "&Submenu1"
.Tag = "SubMenu1"
.BeginGroup = True
End With
With cbSubMenu.Controls.Add(msoControlButton, 1, , , True)
.Caption = "&Submenu Item1"
.OnAction = ThisWorkbook.Name & "!Macroname"
.Style = msoButtonIconAndCaption
.FaceId = 71
.State = msoButtonDown
End With
With cbSubMenu.Controls.Add(msoControlButton, 1, , , True)
.Caption = "&Submenu Item2"
.OnAction = ThisWorkbook.Name & "!Macroname"
.Style = msoButtonIconAndCaption
.FaceId = 72
.Enabled = False
End With
Set cbSubMenu = cbSubMenu.Controls.Add(msoControlPopup, 1, , , True)
With cbSubMenu
.Caption = "&Submenu2"
.Tag = "SubMenu2"
.BeginGroup = True
End With
With cbSubMenu.Controls.Add(msoControlButton, 1, , , True)
.Caption = "&Submenu Item1"
.OnAction = ThisWorkbook.Name & "!Macroname"
.Style = msoButtonIconAndCaption
.FaceId = 71
.State = msoButtonDown
End With
With cbSubMenu.Controls.Add(msoControlButton, 1, , , True)
.Caption = "&Submenu Item2"
.OnAction = ThisWorkbook.Name & "!Macroname"
.Style = msoButtonIconAndCaption
.FaceId = 72
.Enabled = False
End With
Set cbSubMenu = Nothing
Set cbMenu = Nothing
End Sub
Lo que no es como hacerle para asignarle las macros, es decir,
Mi menu va hacer el siguiente:
Mi menu
Ir a Sueldo
Despensa
Primas Vac
Caratula
Recibos
Imprimir Sueldo
Despensa
Prima Vac
Caratula
Recibos
Convertir a PDF
Acerca de?
Ya tengo las macros pero donde se las coloco, ya que si me voy a Mi Menu me dice Que no se Puede encontrar la macro
Gracias por su ayuda
Encontre esta Macro para crear mi menu
Sub CreateMenu()
Dim cbMenu As CommandBarControl, cbSubMenu As CommandBarControl
Set cbMenu = Application.CommandBars(1).Controls.Add(msoControlPopup, , , , True)
With cbMenu
.Caption = "&Mi menu"
.Tag = "MyTag"
.BeginGroup = False
End With
If cbMenu Is Nothing Then Exit Sub
With cbMenu.Controls.Add(msoControlButton, 1, , , True)
.Caption = "&Menu Item1"
.OnAction = ThisWorkbook.Name & "!Macroname"
End With
With cbMenu.Controls.Add(msoControlButton, 1, , , True)
.Caption = "&Menu Item2"
.OnAction = ThisWorkbook.Name & "!Macroname"
End With
Set cbSubMenu = cbMenu.Controls.Add(msoControlPopup, 1, , , True)
With cbSubMenu
.Caption = "&Submenu1"
.Tag = "SubMenu1"
.BeginGroup = True
End With
With cbSubMenu.Controls.Add(msoControlButton, 1, , , True)
.Caption = "&Submenu Item1"
.OnAction = ThisWorkbook.Name & "!Macroname"
.Style = msoButtonIconAndCaption
.FaceId = 71
.State = msoButtonDown
End With
With cbSubMenu.Controls.Add(msoControlButton, 1, , , True)
.Caption = "&Submenu Item2"
.OnAction = ThisWorkbook.Name & "!Macroname"
.Style = msoButtonIconAndCaption
.FaceId = 72
.Enabled = False
End With
Set cbSubMenu = cbSubMenu.Controls.Add(msoControlPopup, 1, , , True)
With cbSubMenu
.Caption = "&Submenu2"
.Tag = "SubMenu2"
.BeginGroup = True
End With
With cbSubMenu.Controls.Add(msoControlButton, 1, , , True)
.Caption = "&Submenu Item1"
.OnAction = ThisWorkbook.Name & "!Macroname"
.Style = msoButtonIconAndCaption
.FaceId = 71
.State = msoButtonDown
End With
With cbSubMenu.Controls.Add(msoControlButton, 1, , , True)
.Caption = "&Submenu Item2"
.OnAction = ThisWorkbook.Name & "!Macroname"
.Style = msoButtonIconAndCaption
.FaceId = 72
.Enabled = False
End With
Set cbSubMenu = Nothing
Set cbMenu = Nothing
End Sub
Lo que no es como hacerle para asignarle las macros, es decir,
Mi menu va hacer el siguiente:
Mi menu
Ir a Sueldo
Despensa
Primas Vac
Caratula
Recibos
Imprimir Sueldo
Despensa
Prima Vac
Caratula
Recibos
Convertir a PDF
Acerca de?
Ya tengo las macros pero donde se las coloco, ya que si me voy a Mi Menu me dice Que no se Puede encontrar la macro
Gracias por su ayuda
1 respuesta
Respuesta de dpizzio
1