- 帖子
- 97
- 主題
- 33
- 精華
- 0
- 積分
- 129
- 點名
- 0
- 作業系統
- Win 7
- 軟體版本
- office 2007
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2019-5-7
- 最後登錄
- 2022-8-25
|
2#
發表於 2019-7-24 17:05
| 只看該作者
回復 1# s13030029
Thisworkbook 程式碼- '自訂工具列
- Dim Abar As CommandBar '宣告工具列物件
- Private Sub Workbook_Open()
- C = MsgBox("功能選單在上方工具列的「增益集」裡!!!", vbExclamation, "使用方法")
- For Each Abar In Application.CommandBars
- If Not Abar.BuiltIn Then Abar.Delete
- Next
- '宣告工具列按鈕物件
- Dim myButton1 As CommandBarButton '選擇使用說明
- Dim myButton2 As CommandBarButton '選擇管制計畫表
-
- '新增一個工具列
- Set Abar = Application.CommandBars.Add(Name:="畫面選擇")
- With Abar
- '畫面選擇----------------------------------------------
- '使用說明
- Set myButton1 = .Controls.Add(msoControlButton)
- With myButton1
- .Style = msoButtonIconAndCaption '同時顯示文字和小圖示
- .BeginGroup = True
- .Caption = "使用說明" '顯示在工具列上的按鈕文字
- '.TooltipText = "畫面選擇" '滑鼠移過去時,所顯示的提示文字
- .FaceId = 487 '小圖示
- .Tag = "MyCustomTag"
- .OnAction = "選擇使用說明" '設定按下此鍵時所要執行的巨集
- End With
- '管制計畫表
- Set myButton2 = .Controls.Add(msoControlButton)
- With myButton2
- .Style = msoButtonIconAndCaption '同時顯示文字和小圖示
- .BeginGroup = True
- .Caption = "管制計畫表" '顯示在工具列上的按鈕文字
- '.TooltipText = "畫面選擇" '滑鼠移過去時,所顯示的提示文字
- .FaceId = 69 '小圖示
- .Tag = "MyCustomTag"
- .OnAction = "選擇管制計畫表" '設定按下此鍵時所要執行的巨集
- End With
- .Position = msoBarTop '工具列擺放在上層
- .Visible = True
- End With
- End Sub
- Private Sub Workbook_BeforeClose(Cancel As Boolean)
- Dim Abar As CommandBar
- For Each Abar In Application.CommandBars
- If Not Abar.BuiltIn Then Abar.Delete
- Next
- End Sub
複製代碼 |
|