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
複製代碼
作者: jackyq 時間: 2019-7-24 18:03
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Excel.Application.Workbooks.Count = 1 Then
Dim Abar As CommandBar
For Each Abar In Application.CommandBars
If Not Abar.BuiltIn Then Abar.Delete
Next
End If
Private Sub Workbook_Open()
' For Each Abar In Application.CommandBars
' If Not Abar.BuiltIn Then Abar.Delete
' Next
'宣告工具列按鈕物件
Dim myButton1 As CommandBarButton '選擇使用說明
Dim myButton2 As CommandBarButton '選擇管制計畫表
'新增一個工具列 on error resume next
Set Abar = Application.CommandBars.Add(Name:="畫面選擇") if err then exit sub
on error goto 0
C = MsgBox("功能選單在上方工具列的「增益集」裡!!!", vbExclamation, "使用方法")
With Abar
'畫面選擇----------------------------------------------
'使用說明
Set myButton1 = .Controls.Add(msoControlButton)
With myButton1
.Style = msoButtonIconAndCaption '同時顯示文字和小圖示
.BeginGroup =
'自訂工具列
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 作者: s13030029 時間: 2019-8-7 13:19
回復 8#jackyq
謝謝大大~這是我要的~~
不過我想請問下面這段是什麼樣的用法???
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
Workbook_Open
End Sub
是當視窗活動時再執行一次Workbook_Open嗎?作者: jackyq 時間: 2019-8-7 21:14