Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub CreateToolBarMenu()
  2. On Error GoTo ErrControl
  3. Dim cbrNewToolBar As CommandBar
  4. Dim cmdNewButton As CommandBarButton
  5. Dim ArrButtons As Variant
  6. Dim intCount As Integer
  7.    '
  8.   ' RemoveBar "mnuItens"
  9.    ArrButtons = Array( _
  10.                     Array("Adicionar", "Adiciona Novo Item", 462, "AddItem"), _
  11.                     Array("Excluir", "Exclui item selecionado", 464, "DelItem"), _
  12.                     Array("Atualizar", "Recarrega o grid", 1759, "Refresh"), _
  13.                     Array("Editar", "Editar item atual", 162, "EditItem"), _
  14.                     Array("Imprimir", "Imprime a folha", 2521, "Print") _
  15.                     )
  16.     Set cbrNewToolBar = Application.CommandBars.Add(Name:="mnuItens", Position:=msoBarPopup, Temporary:=False)
  17.     For intCount = 0 To UBound(ArrButtons, 1)
  18.         Set cmdNewButton = cbrNewToolBar.Controls.Add(msoControlButton)
  19.         With cmdNewButton
  20.             .OnAction = "=Teste()"
  21.             .Style = msoButtonIconAndCaption
  22.             .Caption = ArrButtons(intCount)(0) '"Salvar"
  23.            .DescriptionText = ArrButtons(intCount)(1)    '"Salvar alterações"
  24.            .FaceId = ArrButtons(intCount)(2)
  25.             .Tag = ArrButtons(intCount)(3)
  26.         End With
  27.     Next intCount
  28.     cbrNewToolBar.Enabled = True
  29. Finally:
  30.     Exit Sub
  31. ErrControl:
  32.     msgBox "Erro ao criar botoes!" & vbLf & "Por favor reinicie o sistema e tente novamente." & vbLf & "se o erro persistir contate a area de TI"
  33.     Resume Finally
  34.    
  35. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement