ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¦p¦óÅý¤w©w¸q¥¨¶°ªº«ö¶s¦b¤Á´«¤£¦P¤À­¶®É³£¥i³Q¬Ý¨ì(¤w¸Ñ¨M)

´¿¦¬¶°¨ìÃþ¦ü¤À¨É¡A¥HVBA ¼g©ó  Workbook  ¶}±Ò¦Û©w¸q«ö¶s¡A©óÃö³¬Àɮ׮ɧR°£
¦ý¥¼¸Ô²Ó¬ã¨s¨ä¼gªk¡A¥u§ó§ï¦Û¤v±ý©w¸qªº¦a¤è
¥i¶}±Òªþ¥ó¦Û¦æ¬ã¨s§Y¥i¡A­Y¹ï VBA ¦³°ò¦À³¸Ó¥i»´©öª¾¹D¸Ó§ó§ï¦a¤è
­Y·Qª¾¹D¸Ô²Ó¼gªk§t·N¡A»Ý¨ä¥L°ª¤â¨ó§UÄÀºÃ¡A
§Ú¥uª¾¹D¬Y¨Ç°Ï¶ô¡A§Æ±æ¦³À°§U

´ú¸Õ­Ó¤Hªí³æ¥¨¶°.rar (8.79 KB) ¤è¦¡

¥D­nVBA ¦p¤U

Private Sub Workbook_BeforeClose(Cancel As Boolean)
   
Sheets("´ú¸Õ").Select
On Error Resume Next
   Application.CommandBars("MyMenu").Delete
   Application.CommandBars("ply").Controls("­Ó¤H¾Þ§@ªí³æ").Delete
   
   
End Sub

Private Sub Workbook_Open()

Sheets("´ú¸Õ").Select

On Error Resume Next
   Application.CommandBars("MyMenu").Delete
   Application.CommandBars("ply").Controls("­Ó¤H¾Þ§@ªí³æ").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 = "­Ó¤H¾Þ§@ªí³æ(&P)"
         .Style = msoButtonIconAndCaption
         .FaceId = 988
         .OnAction = "´ú¸Õ­Ó¤Hªí³æ¥¨¶°"
      End With
   End With
   
   Set MyButton = Application.CommandBars("ply").Controls.Add(msoControlButton, , , 1)
      With MyButton
         .Caption = "­Ó¤H¾Þ§@ªí³æ"
         .Visible = True
         .FaceId = 456
         .OnAction = "´ú¸Õ­Ó¤Hªí³æ¥¨¶°"
      
      End With
      


   
End Sub

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
On Error Resume Next
If Workbooks.Count = 1 Then
   Application.CommandBars("MyMenu").Controls("­Ó¤H¾Þ§@ªí³æ(&P)").Enabled = False

End If

End Sub

TOP

        ÀR«ä¦Û¦b : ÁÀ¨¥¹³¤@¦·²±¶}ªºÂAªá¡A¥~ªí¬üÄR¡A¥Í©Rµu¼È¡C
ªð¦^¦Cªí ¤W¤@¥DÃD