Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("測試").Select
On Error Resume Next
Application.CommandBars("MyMenu").Delete
Application.CommandBars("ply").Controls("個人操作表單").Delete
End Sub
Private Sub Workbook_Open()
Sheets("測試").Select
On Error Resume Next
Application.CommandBars("MyMenu").Delete
Application.CommandBars("ply").Controls("個人操作表單").Delete
Dim MyMenuBar As CommandBar
Dim MyButton As CommandBarButton
Set MyMenuBar = Application.CommandBars.Add
With MyMenuBar
.Visible = True
.Name = "MyMenu"
.Position = msoBarTop
Set MyButton = .Controls.Add
With MyButton
.Visible = True
.Caption = "個人操作表單(&P)"
.Style = msoButtonIconAndCaption
.FaceId = 988
.OnAction = "測試個人表單巨集"
End With
End With
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
On Error Resume Next
If Workbooks.Count = 1 Then
Application.CommandBars("MyMenu").Controls("個人操作表單(&P)").Enabled = False