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

[µo°Ý] ¨â­Ó¤u§@ªíªº commandbar

[µo°Ý] ¨â­Ó¤u§@ªíªº commandbar

§Ú¦³¦Û»s¤u¨ã¦C¡A¦ý¬O·í§Ú¶}±Ò¨â­ÓÀɮסA­nÃö³¬¨ä¤¤¤@­ÓÀɮ׮ɡA¨â­ÓÀɮתºcommandbar³£·|³Q§R±¼¡A­n«ç¼Ë¤~¯àÃö±¼¤@­ÓÀɮ׮ɡAÁÙ¯à«O¯d¤u§@¦C?????????

´ú¸Õ.rar (141.36 KB)

¦^´_ 1# s13030029
Thisworkbook µ{¦¡½X
  1. '¦Û­q¤u¨ã¦C
  2.     Dim Abar As CommandBar    '«Å§i¤u¨ã¦Cª«¥ó

  3. Private Sub Workbook_Open()
  4.     C = MsgBox("¥\¯à¿ï³æ¦b¤W¤è¤u¨ã¦Cªº¡u¼W¯q¶°¡v¸Ì!!!", vbExclamation, "¨Ï¥Î¤èªk")
  5.     For Each Abar In Application.CommandBars
  6.         If Not Abar.BuiltIn Then Abar.Delete
  7.     Next

  8.     '«Å§i¤u¨ã¦C«ö¶sª«¥ó
  9.     Dim myButton1 As CommandBarButton  '¿ï¾Ü¨Ï¥Î»¡©ú
  10.     Dim myButton2 As CommandBarButton  '¿ï¾ÜºÞ¨î­pµeªí
  11.    
  12.    '·s¼W¤@­Ó¤u¨ã¦C
  13.     Set Abar = Application.CommandBars.Add(Name:="µe­±¿ï¾Ü")
  14. With Abar
  15. 'µe­±¿ï¾Ü----------------------------------------------
  16.         '¨Ï¥Î»¡©ú
  17.         Set myButton1 = .Controls.Add(msoControlButton)
  18.         With myButton1
  19.             .Style = msoButtonIconAndCaption '¦P®ÉÅã¥Ü¤å¦r©M¤p¹Ï¥Ü
  20.             .BeginGroup = True
  21.             .Caption = "¨Ï¥Î»¡©ú"            'Åã¥Ü¦b¤u¨ã¦C¤Wªº«ö¶s¤å¦r
  22.             '.TooltipText = "µe­±¿ï¾Ü"        '·Æ¹«²¾¹L¥h®É¡A©ÒÅã¥Üªº´£¥Ü¤å¦r
  23.             .FaceId = 487                    '¤p¹Ï¥Ü
  24.             .Tag = "MyCustomTag"
  25.            .OnAction = "¿ï¾Ü¨Ï¥Î»¡©ú"        '³]©w«ö¤U¦¹Áä®É©Ò­n°õ¦æªº¥¨¶°
  26.         End With
  27.         'ºÞ¨î­pµeªí
  28.         Set myButton2 = .Controls.Add(msoControlButton)
  29.         With myButton2
  30.             .Style = msoButtonIconAndCaption '¦P®ÉÅã¥Ü¤å¦r©M¤p¹Ï¥Ü
  31.             .BeginGroup = True
  32.             .Caption = "ºÞ¨î­pµeªí"          'Åã¥Ü¦b¤u¨ã¦C¤Wªº«ö¶s¤å¦r
  33.             '.TooltipText = "µe­±¿ï¾Ü"        '·Æ¹«²¾¹L¥h®É¡A©ÒÅã¥Üªº´£¥Ü¤å¦r
  34.             .FaceId = 69                     '¤p¹Ï¥Ü
  35.             .Tag = "MyCustomTag"
  36.            .OnAction = "¿ï¾ÜºÞ¨î­pµeªí"      '³]©w«ö¤U¦¹Áä®É©Ò­n°õ¦æªº¥¨¶°
  37.         End With
  38.         .Position = msoBarTop                '¤u¨ã¦CÂ\©ñ¦b¤W¼h
  39.         .Visible = True
  40. End With
  41. End Sub

  42. Private Sub Workbook_BeforeClose(Cancel As Boolean)
  43.     Dim Abar As CommandBar
  44.     For Each Abar In Application.CommandBars
  45.         If Not Abar.BuiltIn Then Abar.Delete
  46.     Next
  47. End Sub
½Æ»s¥N½X

TOP

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
        
    End Sub

TOP

¦^´_ 3# jackyq
­ì¨Ó¦p¦¹~ÁA¸Ñ¤F~ÁÂÁÂ~~

TOP

¦^´_ 3# jackyq

¤j¤j©p¦n~
§Ú¦³¹J¨ì¤@­Ó°ÝÃD¡A´N¬O²{¦b§Ú¦³¨âÀɮסA¦ý¬O¬O¤£¤@¼Ëªºcommandbar¡A§Ú¥ý¥´¶}¤@­Ó«á¡A¦A¥´¶}²Ä¤G­Ó®É¡A²Ä¤G­Óªºcommandbar·|»\±¼²Ä¤@­Óªºcommandbar¡A¸Ó«ç»ò¿ì@@

TOP

¥»©«³Ì«á¥Ñ jackyq ©ó 2019-8-6 15:56 ½s¿è

Private Sub Workbook_Open()

'    For Each Abar In Application.CommandBars
'         If Not Abar.BuiltIn Then Abar.Delete
'     Next

    '«Å§i¤u¨ã¦C«ö¶sª«¥ó
    Dim myButton1 As CommandBarButton  '¿ï¾Ü¨Ï¥Î»¡©ú
    Dim myButton2 As CommandBarButton  '¿ï¾ÜºÞ¨î­pµeªí
   
   '·s¼W¤@­Ó¤u¨ã¦C
    on error resume next
    Set Abar = Application.CommandBars.Add(Name:="µe­±¿ï¾Ü")
   if err then exit sub
    on error goto 0
    C = MsgBox("¥\¯à¿ï³æ¦b¤W¤è¤u¨ã¦Cªº¡u¼W¯q¶°¡v¸Ì!!!", vbExclamation, "¨Ï¥Î¤èªk")

With Abar
'µe­±¿ï¾Ü----------------------------------------------
        '¨Ï¥Î»¡©ú
        Set myButton1 = .Controls.Add(msoControlButton)
        With myButton1
            .Style = msoButtonIconAndCaption '¦P®ÉÅã¥Ü¤å¦r©M¤p¹Ï¥Ü
            .BeginGroup =

.................................................

TOP

¦^´_ 6# jackyq [
ÁÂÁ¤j¤j~~
³o¼Ëªº¤èªk¬O¥i¥H¥Î
´N¬O¦P®ÉÅã¥Ü
¦ý¬OÁÙ­n·Q·Q­n¦p¦óÁקK¨Ï¥ÎªÌ¥h«ö¨ì¤£¬O¸ÓÀɮתº¤u¨ã¦C¤~¦æ@@
²¦³º¥¨¶°¥Îªº¤£¤@¼Ë...Orz

TOP

'¦Û­q¤u¨ã¦C
Dim Abar As CommandBar    '«Å§i¤u¨ã¦Cª«¥ó
Dim ¤w´£¥Ü As Boolean


Private Sub Workbook_Open()
    If ¤w´£¥Ü = False Then
       ¤w´£¥Ü = True
       C = MsgBox("¥\¯à¿ï³æ¦b¤W¤è¤u¨ã¦Cªº¡u¼W¯q¶°¡v¸Ì!!!", vbExclamation, "¨Ï¥Î¤èªk")
    End If

    For Each Abar In Application.CommandBars
        If Not Abar.BuiltIn Then Abar.Delete
    Next

    '«Å§i¤u¨ã¦C«ö¶sª«¥ó
    Dim myButton1 As CommandBarButton  '¿ï¾Ü¨Ï¥Î»¡©ú
    Dim myButton2 As CommandBarButton  '¿ï¾ÜºÞ¨î­pµeªí
   
   '·s¼W¤@­Ó¤u¨ã¦C
    Set Abar = Application.CommandBars.Add(Name:="µe­±¿ï¾Ü")
With Abar
'µe­±¿ï¾Ü----------------------------------------------
        '¨Ï¥Î»¡©ú
        Set myButton1 = .Controls.Add(msoControlButton)
        With myButton1
            .Style = msoButtonIconAndCaption '¦P®ÉÅã¥Ü¤å¦r©M¤p¹Ï¥Ü
            .BeginGroup = True
            .Caption = "¨Ï¥Î»¡©ú"            'Åã¥Ü¦b¤u¨ã¦C¤Wªº«ö¶s¤å¦r
            '.TooltipText = "µe­±¿ï¾Ü"        '·Æ¹«²¾¹L¥h®É¡A©ÒÅã¥Üªº´£¥Ü¤å¦r
            .FaceId = 487                    '¤p¹Ï¥Ü
            .Tag = "MyCustomTag"
           .OnAction = "¿ï¾Ü¨Ï¥Î»¡©ú"        '³]©w«ö¤U¦¹Áä®É©Ò­n°õ¦æªº¥¨¶°
        End With
        'ºÞ¨î­pµeªí
        Set myButton2 = .Controls.Add(msoControlButton)
        With myButton2
            .Style = msoButtonIconAndCaption '¦P®ÉÅã¥Ü¤å¦r©M¤p¹Ï¥Ü
            .BeginGroup = True
            .Caption = "ºÞ¨î­pµeªí"          'Åã¥Ü¦b¤u¨ã¦C¤Wªº«ö¶s¤å¦r
            '.TooltipText = "µe­±¿ï¾Ü"        '·Æ¹«²¾¹L¥h®É¡A©ÒÅã¥Üªº´£¥Ü¤å¦r
            .FaceId = 69                     '¤p¹Ï¥Ü
            .Tag = "MyCustomTag"
           .OnAction = "¿ï¾ÜºÞ¨î­pµeªí"      '³]©w«ö¤U¦¹Áä®É©Ò­n°õ¦æªº¥¨¶°
        End With
        .Position = msoBarTop                '¤u¨ã¦CÂ\©ñ¦b¤W¼h
        .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

TOP

¦^´_ 8# jackyq
ÁÂÁ¤j¤j~³o¬O§Ú­nªº~~
¤£¹L§Ú·Q½Ð°Ý¤U­±³o¬q¬O¤°»ò¼Ëªº¥Îªk???
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
Workbook_Open
End Sub

¬O·íµøµ¡¬¡°Ê®É¦A°õ¦æ¤@¦¸Workbook_Open¶Ü?

TOP

¦^´_ 9# s13030029


µøµ¡±q «D¬¡°Ê Åܦ¨ ¬¡°Ê ªº¨º¤@ÀK¨º

¦A°õ¦æ¤@¦¸Workbook_Open

TOP

        ÀR«ä¦Û¦b : ¦¨¥\¬OÀuÂIªºµo´§¡A¥¢±Ñ¬O¯ÊÂIªº²Ö¿n¡C
ªð¦^¦Cªí ¤W¤@¥DÃD