- 帖子
- 323
- 主題
- 6
- 精華
- 0
- 積分
- 313
- 點名
- 0
- 作業系統
- xp
- 軟體版本
- 2k
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2015-6-24
- 最後登錄
- 2026-1-5
|
8#
發表於 2019-8-7 09:04
| 只看該作者
'自訂工具列
Dim Abar As CommandBar '宣告工具列物件
Dim 已提示 As Boolean
Private Sub Workbook_Open()
If 已提示 = False Then
已提示 = True
C = MsgBox("功能選單在上方工具列的「增益集」裡!!!", vbExclamation, "使用方法")
End If
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
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
Workbook_Open
End Sub
|
|