Mình có đoạn code từ vba như sau:
Sub DeleteToolbar()
On Error Resume Next
CommandBars("ABC").Delete
On Error GoTo 0
End Sub
Sub Add_Toolbar()
Dim TBar As CommandBar
Dim NewDD As CommandBarControl
Dim NewBtn As CommandBarButton
'delete any previous old copy of Chem Aqua Anco toolbar
DeleteToolbar
'define the Toolbar
Set TBar = CommandBars.Add
With TBar
.Name = "ABC"
.Visible = True
.Position = msoBarBottom
End With
Set NewBtn = TBar.Controls.Add(Type:=msoControlButton)
With NewBtn
.OnAction = "Macro1"
.Caption = "Blah blah blah 1"
.TooltipText = "a tip to help"
.Style = msoButtonCaption
End With
Set NewBtn = TBar.Controls.Add(Type:=msoControlButton)
With NewBtn
.OnAction = "Macro2"
.Caption = "Blah blah blah 2"
.TooltipText = "a tip to help"
.Style = msoButtonCaption
End With
Set NewBtn = TBar.Controls.Add(Type:=msoControlButton)
With NewBtn
.OnAction = "Macro3"
.Caption = "Blah blah blah 3"
.TooltipText = "a tip to help"
.Style = msoButtonCaption
End With
Set NewBtn = TBar.Controls.Add(Type:=msoControlButton)
With NewBtn
.OnAction = "Macro4"
.Caption = "Blah blah blah 4"
.TooltipText = "a tip to help"
.Style = msoButtonCaption
End With
Set NewBtn = TBar.Controls.Add(Type:=msoControlButton)
With NewBtn
.OnAction = "Macro5"
.Caption = "Blah blah blah 5"
.TooltipText = "a tip to help"
.Style = msoButtonCaption
End With
Set NewBtn = TBar.Controls.Add(Type:=msoControlButton)
With NewBtn
.OnAction = "Macro6"
.Caption = "Blah blah blah 6"
.TooltipText = "a tip to help"
.Style = msoButtonCaption
End With
Set NewBtn = TBar.Controls.Add(Type:=msoControlButton)
With NewBtn
.OnAction = "Macro7"
.Caption = "Blah blah blah 7"
.TooltipText = "a tip to help"
.Style = msoButtonCaption
End With
End Sub
Mình muốn chuyển sang dll mong các bạn giúp đỡ. Mình thử nhưng không chạy
Sub DeleteToolbar()
On Error Resume Next
CommandBars("ABC").Delete
On Error GoTo 0
End Sub
Sub Add_Toolbar()
Dim TBar As CommandBar
Dim NewDD As CommandBarControl
Dim NewBtn As CommandBarButton
'delete any previous old copy of Chem Aqua Anco toolbar
DeleteToolbar
'define the Toolbar
Set TBar = CommandBars.Add
With TBar
.Name = "ABC"
.Visible = True
.Position = msoBarBottom
End With
Set NewBtn = TBar.Controls.Add(Type:=msoControlButton)
With NewBtn
.OnAction = "Macro1"
.Caption = "Blah blah blah 1"
.TooltipText = "a tip to help"
.Style = msoButtonCaption
End With
Set NewBtn = TBar.Controls.Add(Type:=msoControlButton)
With NewBtn
.OnAction = "Macro2"
.Caption = "Blah blah blah 2"
.TooltipText = "a tip to help"
.Style = msoButtonCaption
End With
Set NewBtn = TBar.Controls.Add(Type:=msoControlButton)
With NewBtn
.OnAction = "Macro3"
.Caption = "Blah blah blah 3"
.TooltipText = "a tip to help"
.Style = msoButtonCaption
End With
Set NewBtn = TBar.Controls.Add(Type:=msoControlButton)
With NewBtn
.OnAction = "Macro4"
.Caption = "Blah blah blah 4"
.TooltipText = "a tip to help"
.Style = msoButtonCaption
End With
Set NewBtn = TBar.Controls.Add(Type:=msoControlButton)
With NewBtn
.OnAction = "Macro5"
.Caption = "Blah blah blah 5"
.TooltipText = "a tip to help"
.Style = msoButtonCaption
End With
Set NewBtn = TBar.Controls.Add(Type:=msoControlButton)
With NewBtn
.OnAction = "Macro6"
.Caption = "Blah blah blah 6"
.TooltipText = "a tip to help"
.Style = msoButtonCaption
End With
Set NewBtn = TBar.Controls.Add(Type:=msoControlButton)
With NewBtn
.OnAction = "Macro7"
.Caption = "Blah blah blah 7"
.TooltipText = "a tip to help"
.Style = msoButtonCaption
End With
End Sub
Mình muốn chuyển sang dll mong các bạn giúp đỡ. Mình thử nhưng không chạy

Lần chỉnh sửa cuối: