|
发表于 2012-8-23 18:34
|
显示全部楼层
本楼为最佳答案
本帖最后由 柳如烟 于 2012-8-23 18:58 编辑
- Sub 生成工具栏()
- Dim mybar As CommandBar, ctl As CommandBarButton
- Set mybar = CommandBars.Add("我的工具栏", , False, True)
- mybar.Visible = True
- Set ctl = mybar.Controls.Add
- With ctl
- .Caption = "你好"
- .OnAction = "Hello"
- .FaceId = 59
- .Style = msoButtonIconAndCaption
- End With
- End Sub
- Sub Hello()
- MsgBox "您好!"
- End Sub
- Sub 删除工具栏()
- On Error Resume Next
- CommandBars("我的工具栏").Delete
- End Sub
- Private Sub Workbook_BeforeClose(Cancel As Boolean)
- 删除工具栏
- End Sub
- Private Sub Workbook_Open()
- 生成工具栏
- End Sub
复制代码 |
|