????? ????? ??????? ?????? ??????? ?? Excel?

?????? ????????? ?????? ?????????
???? ???????: 830502 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ????? ????? ??????? ?????? ??????? ?? Microsoft Excel 2000 ?????????? ??????. ??? ???? ????? ??? ??????? ???? ????? ?????? ?? ????????? ???????? ?????? ??????? ?????? ??????? ???????? ???????? ??????? ???????? ???????? ?? Microsoft Excel ???????? ???????.

?????

?????? ?????? ?? ?????? ?????? ???????? ?????? ????? ??????? ???????? ?? Microsoft Excel 2000 ?Microsoft Excel 2002 ?Microsoft Office Excel 2003? ?????? ???? ?????? ?????. ?????? ?????? ?? ?????? ???????? ?? ?????? ????? ????? ?? ????? ??????? ????? ?? ????? ??? ????? ????????? ???????? ?????? ?? Microsoft Visual Basic for Applications (VBA).

????? ?? ????????? ??? ????? ??????? ???? ?????? "?????"? ???? ??? ??????? Microsoft Excel ?? ??????? ???????? ?? ???? ????? ???? ??????? ?? "????? Office" ?? ?? "????? ???????"? ?? ???? ??? ??? ???? ???????.

?????? ??? ??????? ?? ?????? ??? ???????? ?????? ?????? ???????? ???????? ?????? ?? VBA ?????? ????? ??????? ???????? ?????? ??????? ???????? ??????? ???????? ????????.

??????? ????

???? Microsoft ??????? ???????? ???? ??????? ???? ??? ?? ???? ???? ?? ????. ?????? ??? ???????? ??? ???? ?????? ?? ?????? ???????? ??????? ?????? ???????? ?? ???????? ???? ????. ?????? ??? ??????? ??? ??? ????? ???? ??????? ???? ??? ????? ???????? ????????? ?????? ????????? ????????. ???? ??????? ????? ??? Microsoft ??? ??????? ?????? ?????? ????? ??? ???? ?? ?????? ?????? ??? ??????? ?????? ????? ?????? ?? ????? ??????? ?????? ??????? ?????.

??????? ?? ??? ???????

?????? ??????? ???????? ?? ??? ??????? ???????? ???????? ?????? ?? VBA ?? Excel 2000 ??? Excel 2002 ??? Excel 2003 ?????? ???????. ???????? ????? ??????? ?????? ???????? ???? ????? ??????? ???????:
  1. ?? ?????? Excel.
  2. ?? ??????? ?????? ??? ??? ?????? ?? ???? ??? ???? Visual Basic.
  3. ?? ??????? Insert? ???? ??? Module.
  4. ???? ??? ????? ??????? ???????? ?? ??? ???????? ?? ????? ??????? ????? ????? ?????? ???? ????? ????? ??? ???? ???? ?????.
  5. ?? ??????? Run? ???? ??? Run Sub/UserForm.
  6. ??? ??? ???? ?????? Macro? ???? ??? ??? ???????? ?? ???? ??? Run.

????? ???????

?? Microsoft Office? ??? ?????? ?? ?? ?? ????? ??????? ?????? ??????? ???????? ???????? ???? ????? ????????? ??? ????? ????????: ????? ???????. ????? ???? ??????? ??????? ?? VBA ?? ???? ?????? CommandBar:
  • ????? ??????? ?????? ??????? ???????? ????????.
  • ??????? ???????? ??? ????? ??????? ?????? ???????.
  • ??????? ??????? ???????? ???????? ???????? ??????? ???????? ????????.
????? ????? ?? ???? ????? ???? ?? ?? ???? ????? ????? ??? ????? ????? ????? ????? ????? ?????? ????? ?????? ?????? ???????? ???????? ?? ???????? ???????? ?????? ?? VBA. ?????? ????? ????? ???????? ????? ?? ?????? ????? ??? ????? ??????? ?? ???????? ?????? ??????? ?? ???????. ?????? ??? ???? ?? ????? ??????? ???????? ????? ????? ?????? ???? ?????? ??? ????? ????? ??????.

?? ?? ?? VBA ?Microsoft Visual Basic? ??? ????? ????? ??????? ???????? ?? ???? ?????? CommandBarButton. ???? ????? ????? ?????? ???????? ???? ???? ??????? ???????? ??????? ?? ???? ?????? CommandBarPopup. ?? ??????? ???????? ????? ?? ?? ???? ?????? ?????? "?????" ????? ?????? ?????? "????? ?????" ????? ???? ?????? ???? ????? ?????? ?????. ?????? ?? ?? ??????? ???????? ??????? ?????? CommandBar ????? ????? ??? ?????? ????? ?????? ?????? ???.

?? Microsoft Excel? ??? ??????? ??? ????? ??????? ?????? ??????? ???? ??? ?????? ?????? ???????? ??? ???? CommandBar. ????? ??????? ????? ?????? ???????? ?? ???? CommandBar ??????? ??? ??????? ?????? ??????? ???????? ??????? ???????? ????????. ????? ??????? ???? ?? ?? ???? ???? ?? ????? Type ?????? ??? ???? ?????? ???? ???? ???????? ??????? ?? ??????? ??????? ?? ?????.

????? ????? ??????

???? ??? ????? ?????? ????? ?????? ???????? ?? Excel 2003 ????? ???? ??? ???? ?????? ??????? ??????? ???????? ?? ???? ???? ???? ????? ????:
  • MsoControlActiveX*
  • MsoControlAutoCompleteCombo***
  • MsoControlButton
  • MsoControlButtonDropdown
  • MsoControlButtonPopup
  • MsoControlComboBox
  • MsoControlCustom
  • MsoControlDropdown
  • MsoControlEdit
  • MsoControlExpandingGrid
  • MsoControlGauge
  • MsoControlGenericDropdown
  • MsoControlGraphicCombo
  • MsoControlGraphicDropdown
  • MsoControlGraphicPopup
  • MsoControlGrid
  • MsoControlLabel
  • MsoControlLabelEx***
  • MsoControlOCXDropDown
  • MsoControlPane **
  • MsoControlPopup
  • MsoControlSpinner***
  • MsoControlSplitButtonMRUPopup
  • MsoControlSplitButtonPopup
  • MsoControlSplitDropdown
  • MsoControlSplitExpandingGrid
  • MsoControlWorkPane**
* = ???? ?? Microsoft Excel 2000
** = ???? ?? Microsoft Excel 2002
*** = ???? ?? Microsoft Office Excel 2003

????? ???????

????? ???? ??????? ??? ????? ????? ???????. ??? ????? ?? ??? ?? ???????? ????? ????? ????? ?????? ????? ?????? ????? ??.

????? ?? ????????? ??? ????? ????? ????? ??????? ?????? ??????? ?? Excel? ???? ??????? ???????:
  1. ?? ?????? ???? Microsoft Visual Basic.
  2. ?? ??????? Help? ???? ??? ??????? Microsoft Visual Basic.
  3. ?? ?????? ????? Office ?? ?? ?????? ????? ???????? ???? Menu bars? ?? ???? ??? ???.
  4. ?? Excel 2003 ?Excel 2002? ???? ??? Adding and Managing Menu Bars and Menu Items. ?? Excel 2000? ???? ??? About menus and toolbars.
????? ????? ??????? ??? ?? ?? ???? ??????? ?????? ?????? ???????? ??? ???? ??????? ??? ?? ??? ???????. ??? ???? ??? ????????? ???? ???? ??? ??? ???? ??????? ??? ????? ?? ?????. ????? ????? ????????? ???? ???? ??? ??? ????? ?????? ??? ??? ???? ??????. ???? ?????? ?????? ??????? ?????? ?????? ?????? ??????? ?????? ?????? ?? ??????? ?? ??????? ???? ????:
?? ??? ??????????? ??? ??????
??????? ?? ????????????
Add????? ???? ????? ???????? ??????? Add ????? ??????? ?????? CommandBars ??????? ?????? TRUE ?????? Menubar.
Enabled?? ???? ????? ??????? Enabled ??? ?????? TRUE? ???? ???????? ?? ???? ???? ??????? ?????? ?????? ???????? ????????? ???????? ?? Visual Basic. ?? ???? ????? ??????? Enabled ??? ?????? FALSE? ?? ???? ???????? ?? ???? ???? ??????? ??????. ??? ???? ????? ???? ??????? ?? ????? ????? ??????? ????????.
Protection???? ?? ??????? ????? ???? ??????? ?? ??????? ?????? ?????.
Position????? ???? ???? ??????? ?????? ??????? ????? ????????. ?? ???? ???? ???? ??????? ??????? ????? ???????? ????? ?? ????? ?????? MsoBarPosition: msoBarLeft ?? msoBarTop ?? msoBarRight ?? msoBarBottom ?? msoBarFloating ?? msoBarPopup (????????? ?????? ??????? ????????) ?? msoBarMenuBar (????????? ?? Apple Macintosh ???).
Visible????? ?? ??? ??? ???? ?????? ?????? ?? ??????.

????? ???? ????? ???? ???? ???????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ???? ????? ??????? ?????:
Sub Id_Control ()
Dim myId as Object
   set myId = CommandBars("Worksheet Menu Bar").Controls("Tools")
   MsgBox myId.Caption & Chr(13) & MyId.Id
End Sub

????? ??? ???? ??????? ?????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ??? ???? ??????? ?????:
Sub MenuBars_GetName()
   MsgBox CommandBars.ActiveMenuBar.Name
End Sub

??? ?????? ?????? (?????? ??????? ??????? ?? ???????)

?? ????? ??? ????? ??????? OriginalMenuBar ?????? ??? ???? ???? ?????? ???? ???????? ?? ????? ???? ???? ??? ??????? ?????? Auto_Close. ????? ?? ????? ??????? ????????? ???? ??????? ????? ????? ???? ??????? ?????? ????? ????????? ??? ????? ???????. ???? ????? ??????? ?????? ??? ????? ????? ???? ???????:
Public OriginalMenuBar as Object

Sub MenuBars_Capture()
   Set OriginalMenuBar = CommandBars.ActiveMenuBar
End Sub

????? ???? ????? ????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ???? ????? ???? ????? My Command Bar:
Sub MenuBar_Create()
 Application.CommandBars.Add Name:="My command bar" 
End Sub

????? ????? ????? ???? ????? ???? ?? ???? ??????? ??????? Temporary:=True. ???? ??????? Temporary:=True ?????? ????? ????? ??????? ???????? ????? ???? ?????? Excel. ?????? ???????? ???????? ??????? ??????? Temporary:=True ?????? ???? ????? ????:
Sub MenuBar_Create()
Application.CommandBars.Add Name:="My command bar", Temporary:=True
End Sub

??? ???? ????? ????

???? ?????? ?????? ????? ????? ???? ??????? ?????? My Custom Bar ?????? ?? ????? ??????? ???? ??????? ??????:
Sub MenuBar_Show()
Dim myNewBar As Object
   Set myNewBar = CommandBars.Add(Name:="Custom1", Position:=msoBarFloating)
   ' You must first enable your custom menu bar before you make it visible.
   ' Enabling a menu bar adds it to the list of available menu bars on
   ' the Customize dialog box.
' Setting the menubar property to True replaces the built-in menu bar.
   myNewBar.Enabled = True
   myNewBar.Visible = True
End Sub

??? ???? ????? ????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ??? ???? ??????? ?????? ?????? Custom 1:
Sub MenuBar_Delete()
   CommandBars("Custom1").Delete
End Sub

????? ???? ?????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ???? ??????? ?????? Chart ?? ????? ????? ??????? ????????:
Sub MenuBar_Display()
   CommandBars("Chart").Enabled = False
End Sub

??? ???? ?????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ???? ??????? ?????? Chart ?? ????? ????? ??????? ????????:
Sub MenuBar_Display()
   CommandBars("Chart").Enabled = True
End Sub

??????? ???? ????? ????

???? ????? ??????? ???? ????? ??? ????? ????? ????? ?????? ?????????? (??? ?? ??????? ?????? ???????). ???? ???????? ???????? ???????? ?? ?????? ?????? ??? ??????? ???? ??????? ?????? Chart:
Sub MenuBar_Restore()
   CommandBars("Chart").Reset
End Sub
?????? ????? ??? ????? ????? ????? ??????? ???????. ??? ??? ?? ????? ????? ????? ???? ????? ????.

???????

???? ????? ??????? ???? ????? ??? ????? ????? ????? ?????? ?????????? (??? ?? ??????? ?????? ???????). ???? ???????? ???????? ???????? ?? ?????? ?????? ??? ??????? ???? ??????? ?????? Chart:

Sub MenuBar_Restore()
   CommandBars("Chart").Reset
End Sub
?????? ????? ??? ????? ????? ????? ??????? ???????. ??? ??? ?? ????? ????? ????? ???? ????? ????.

????? ???? ???? ????? ???? ??? ???? ?????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ??? ??????? ???? ??? ???????? ??????? ??? ???? ??????? Worksheet. ??? ???? ??????? ???? ??? ???????? ???????? ??? ????? ??? ??????? New Menu ??? ???? ??????? Worksheet.

?????? ????? ????? ??? ??????? ??? ????.
Sub Menu_Create()
Dim myMnu As Object
   Set myMnu = CommandBars("Worksheet menu bar").Controls. _
      Add(Type:=msoControlPopup, before:=3)
   With myMnu
   ' The "&" denotes a shortcut key assignment (Alt+M in this case).
      .Caption = "New &Menu"
   End With
End Sub

????? ???? ???? ????? ????? ?????

???? ???? ???? ??????? ?????? ??? ??? ??? ???? ?????? ??? ???? ???????. ???? ?????? ?????? ????? ????? ??????? New Menu:
Sub Menu_Disable()
   CommandBars("Worksheet menu bar").Controls("New &Menu").Enabled = False
End Sub

????? ???? ???? ????? ????? ?????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ??????? New Menu ????? ??? ???????? ?? ??? "????? ???? ???? ????? ????? ?????":
Sub Menu_Disable()
   CommandBars("Worksheet menu bar").Controls("New &Menu").Enabled = True
End Sub

??? ???? ???? ????? ?? ???? ?????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ??? ??????? New Menu ????? ??? ???????? ?? ??? "????? ???? ???? ????? ???? ??? ???? ?????" ?? ???? ??????? Worksheet:
Sub Menu_Delete()
   CommandBars("Worksheet menu bar").Controls("New &Menu").Delete
End Sub

??????? ???? ???? ????? ??? ???? ?????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ??????? ???? ??????? ?????? Chart ??? ???? ??????? Worksheet:
Sub Menu_Restore()
Dim myMnu As Object
   Set myMnu = CommandBars("Chart")
   myMnu.Reset
End Sub

???????

?? ???? ????????? ???? ????? ??????? ??? ??? ??????? ????? ??? ??? ???? ??????. ????? ???? ??? ????? ??????? ?? ???????. ????? ?????? ??????? ??????? ??????? ???????? ??????? ??????? ?????? ???? ?????? ??????? ???? ????? ????? ????? ??? ??????? ?? ??????? ????. ???????? ??? ???? ????? ????? ??????? ???? ?? ?????? ?? ?????? ????? ??? ???? ??????? ???? ?? ??????? ?? ???????. ??? ????? ????? ??????? ????? ??? ???? ???? ??? ????? ????? ?? ????? ?????.

???? ?????? ?????? ??????? ?????? ?????? ?????? ????? ???? ???? ????? ?????? ?? ??????? ?? ??????? ???? ????:
?? ??? ??????????? ??? ??????
??????? ?? ????????????
Add????? ??? ??? ???? ?????.
AddItem????? ???? ??? ??? ??????? ???????? ????? ????? ????? ?????? ?? ????? ????? ????.
Style????? ?? ??? ??? ??? ???? ???? ??? ?? ????? ???????.
OnAction????? ??????? ???? ??? ?????? ????? ???? ???????? ?????? ???? ???? ??????.
Visible????? ?? ??? ??? ???? ?????? ?????? ?? ??????.

????? ?? ????????? ??? ??????? ?? Excel 2003 ?Excel 2002? ???? ????? ??????? ???????:
  1. ?? ?????? ???? Visual Basic Script.
  2. ?? ??????? Help? ???? ??? ??????? Microsoft Visual Basic.
  3. ?? ?????? ??????? ?????? ???? menus? ?? ???? ????? ENTER.
  4. ???? ??? Adding and Managing Menu Bars and Menu Items (Office).

????? ???? ???? ??? ???? ???? ?????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ???? ???? ??? ????? Worksheet ???????? Insert:
Sub menuItem_AddSeparator()
   CommandBars("Worksheet menu bar").Controls("Insert") _
   .Controls("Worksheet").BeginGroup = True
End Sub
?????? ?????? ???? ????? ?? ?????? ??????? BeginGroup ??? ?????? False.

????? ???? ???? ??? ???? ?? ?????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ??? ???? ???? Custom1 ?? ??????? Tools ??? ???? ??????? Worksheet ?? ??? ????? ??????? Code_Custom1 ??? ????? ??? Custom1:
Sub menuItem_Create()
   With CommandBars("Worksheet menu bar").Controls("Tools")
      .Controls.Add(Type:=msoControlButton, Before:=1).Caption = "Custom1"
      .Controls("Custom1").OnAction = "Code_Custom1"
   End With
End Sub

??? ????? ?????? ????? ???? ???? ???

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ??? ????? ?????? ????? ????? Custom1 ??? ?? ??? ??????? ?? ???? ?????? ????? ???????? ?? ???? ????? ????? Custom1:
Sub menuItem_checkMark()
Dim myPopup as Object

   Set myPopup = CommandBars("Worksheet menu bar").Controls("Tools")
   If myPopup.Controls("Custom1").State = msoButtonDown Then
      ' Remove check mark next to menu item.
      myPopup.Controls("Custom1").State = msoButtonUp
      MsgBox "Custom1 is now unchecked"
      Else
        ' Add check mark next to menu item.
         myPopup.Controls("Custom1").State = msoButtonDown
         MsgBox "Custom1 is now checked"
    End If
End Sub

????? ???? ???? ??? ??? ???? ?????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ????? Custom1 ???? ??? ??????? ?? ??????? Tools ???? "????? ???? ???? ??? ???? ?? ?????":
Sub MenuItem_Disable()
Dim myCmd as Object
   Set myCmd = CommandBars("Worksheet menu bar").Controls("Tools")
   myCmd.Controls("Custom1").Enabled = False
End Sub

????? ???? ???? ??? ??? ???? ?????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ????? Custom1 ????? ??? ??????? ?? ??? "????? ???? ???? ??? ??? ???? ?????":
Sub MenuItem_Enable()
Dim myCmd as Object
   Set myCmd = CommandBars("Worksheet menu bar").Controls("Tools")
   myCmd.Controls("Custom1").Enabled = True
End Sub

??? ???? ???? ??? ?? ?????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ??? ????? Save ?? ??????? File:
Sub menuItem_Delete()
Dim myCmd As Object
   Set myCmd = CommandBars("Worksheet menu bar").Controls("File")
   myCmd.Controls("Save").Delete
End Sub

??????? ???? ???? ??? ???? ?? ?????

???????? ???? ???? ??? ?? ?????? ??? ????? ??? ?????? ????? ????? ??????. ?????? ??? ??????? ???? ??? "????? ???? ????? ???? ???? ?????". ???? ?????? ?????? ????? ??? ????? Save ?? ???????? ??? ????? ???? ??? ????? ?? ??? "??? ???? ???? ??? ?? ?????":
Sub menuItem_Restore()
Dim myCmd As Object
   Set myCmd = CommandBars("Worksheet menu bar").Controls("File")
   ' Id 3 refers to the Save menu item control.
   myCmd.Controls.Add Type:=msoControlButton, ID:=3, Before:=5
End Sub

??????? ???????

???? ??????? ??????? ????? ??????? ??????? ????? ???? ?????? ??? ??? ???????. ????? ????? ???? ????? ???? ???? ????? ????? ??? ??? ???? ???? ????? ??? ????? ?????? ?? ??? ?????.

????? ????? ?????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ????? ????? ????? ???? NewSub ??? ??????? Tools ???????? ??? ???? ??????? Worksheet:
Sub SubMenu_Create()
Dim newSub as Object
   Set newSub = CommandBars("Worksheet menu bar").Controls("Tools")
   With newSub
      .Controls.Add(Type:=msoControlPopup, Before:=1).Caption="NewSub"
   End With
End Sub

????? ??? ??? ????? ?????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ??? ???? ???? SubItem1 ??? ??????? ??????? NewSub? ?? ??? ????? ??????? Code_SubItem1 ??? ????? ??? SubItem1:
Sub SubMenu_AddItem()
Dim newSubItem as Object
   Set newSubItem = CommandBars("Worksheet menu bar") _
   .Controls("Tools").Controls("NewSub")
   With newSubItem
      .Controls.Add(Type:=msoControlButton, Before:=1).Caption = "SubItem1"
      .Controls("SubItem1").OnAction = "Code_SubItem1"
   End With
End Sub

????? ???? ???? ??? ?? ????? ?????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ??? ????? SubItem ???? ??? ??????? ?? ??? "????? ??? ??? ????? ?????":

Sub SubMenu_DisableItem()
   CommandBars("Worksheet menu bar").Controls("Tools") _
   .Controls("NewSub").Controls("SubItem1").Enabled = False
End Sub


???? ?????? ?????? ????? ????? ??? ????? SubItem:
Sub SubMenu_DisableItem()
   CommandBars("Worksheet menu bar").Controls("Tools") _
   .Controls("NewSub").Controls("SubItem1").Enabled = True
End Sub

??? ??? ?? ????? ?????

???? ?????? ?????? ????? ??? ????? SubItem1 ???? ??? ??????? ?? ??????? ??????? NewSub ?? ??? "????? ??? ??? ????? ?????":
Sub SubMenu_DeleteItem()
   CommandBars("Worksheet menu bar").Controls("Tools") _
   .Controls("NewSub").Controls("SubItem1").Delete
End Sub

????? ???? ???? ????? ?????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ??????? ??????? NewSub ???? ??? ???????? ?? ??????? Tools ?? ??? "????? ????? ?????":
Sub SubMenu_DisableSub()
   CommandBars("Worksheet menu bar").Controls("Tools") _
   .Controls("NewSub").Enabled = False
End Sub
?????? ?????? ???? ?????? ??????? ?? ?????? ??????? Enabled ??? ?????? True.

??? ???? ???? ????? ?????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ??? ??????? ??????? NewSub ???? ??? ???????? ?? ??????? Tools ?? ????? "????? ????? ?????":
Sub SubMenu_DeleteSub()
   CommandBars("Worksheet menu bar").Controls("Tools") _
   .Controls("NewSub").Delete
End Sub

????? ??????? ????????

????? ??????? ???????? ???? ????? ???? ???? ????? ???? ???????? ?????? ??? ?????? ?????? ??? ??? ????????. ???? ?? ????? ???? ??????? ???????? ??? ??? ????? ????? ?????? ???????? ??? ???? ????? ????? ????? ?????? ???? ????? ????? ?????? ???????? ??? ???? ?????. ?? ????? ????? ????? ?????? ?? ??????? ?? ????? ???????? ?????? ????? ???????. ?????? ??? ????? ??????? ???????? ?????? ?? ???????? ?? ??? ???????.

????? ?? ????????? ??? ??????? ???????? ?? Excel 2003 ?Excel 2002? ???? ??????? ???????:
  1. ?? ?????? ???? Visual Basic Script.
  2. ?? ??????? Help? ???? ??? ??????? Microsoft Visual Basic.
  3. ?? ?????? ??????? ?????? ???? shortcut? ?? ???? ????? ENTER.
  4. ???? ??? Adding and Displaying Shortcut Menus.

????? ???? ????? ?????? ????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ???? ????? ?????? ???? ???? myShortcutBar:

Sub Shortcut_Create()
Dim myShtCtBar as Object
   Set myShtCtBar = CommandBars.Add(Name:="myShortcutBar", _
   Position:=msoBarPopup)
   ? This displays the shortcut menu bar.
   ? 200, 200 refers to the screen position in pixels as x and y coordinates.
   myShtCtBar.ShowPopup 200,200
End Sub

?????? ???? ???? ??????? ???????? ?????? ????? ???? ?? ??? ????? ??? ????? ???? (????? ????? ?? ????? ?????) ????.

??????? ????????

???? ????? ??????? ???????? ??? ????? ??? ?????? ?????? ??? ???? Excel ????. ????? Excel ??? ????? ????? ?????? ????? ??? ????? ?????? ?????? ?? ???????. ????? ????? ????? ????? ????? ?????? ????? ?????? ????? ??????? ???????.

????? ??? ??? ???? ????? ??????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ??? ????? ???? ???? Item1 ?? ???? ??????? ???????? myShortcutBar ??? ???? ??? ????? ??????? Code_Item1 ??? ????? ??? Item1:
Sub Shortcut_AddItem()
Dim myBar as Object
   Set myBar = CommandBars("myShortcutBar")
   With myBar
      .Controls.Add (Type:=msoControlButton, before:=1).Caption = "Item1"
      .Controls("Item1").OnAction = "Code_Item1"
   End With
   myBar.ShowPopup 200,200
End Sub

????? ???? ???? ??? ??? ???? ????? ??????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ????? Item1 ???? ??? ??????? ?? ??? "????? ??? ?? ????? ??????":
Sub Shortcut_DisableItem()
   Set myBar = CommandBars("myShortcutBar")
   myBar.Controls("Item1").Enabled = False
   myBar.ShowPopup 200,200
End Sub
?????? ?????? ?????? ??????? ?? ?????? ??????? Enabled ??? ?????? True.

??? ??? ?? ???? ????? ??????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ??? ??? ??????? ?????? Item1 ??????? ??? ???? ??????? ???????? myShortcutBar:
Sub Shortcut_DeleteItem()
   Set myBar = CommandBars("myShortcutBar")
   myBar.Controls("Item1").Delete
   myBar.ShowPopup 200,200
End Sub

??? ???? ????? ??????

???? ????? ??? ???? ??????? ???????? ??? ????? ???? ???????. ??? ????? ??????? ???? ????? ???? ?? ????. ?????????? ??? ????? ?????? ?????? ????? ???? ????? ??????? ???????? ???????.

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ??? ???? ??????? ???????? myShortCutBar ???? ??? ??????? ?? ??? "????? ??? ??? ???? ????? ??????":
Sub Shortcut_DeleteShortCutBar()
   CommandBars("MyShortCutBar").Delete
End Sub

??????? ??? ??? ???? ????? ?????? ????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ??????? ??????? ?????????? ????? ??????? ???????? Cell ????? ????? ?????:
Sub Shortcut_RestoreItem()
   CommandBars("Cell").Reset
End Sub

??????? ??????? ??????? ????????

????? ????? ????? ????? ??? ????? ??????? ????????. ??? ???? ??????? ??????? ????? ??????? ??????? ????? ???? ?????? ??? ??? ????? ?????? ?????? ??????. ????? ????? ???? ????? ???? ???? ????? ????? ??? ??? ???? ???? ????? ??? ???? ??? ?????.

????? ????? ????? ????? ??? ???? ????? ??????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ????? ????? ????? ???? NewSub ??? ??????? ???????? Cell ?????? ????? ?????:
Sub ShortcutSub_Create()
   CommandBars("Cell").Controls.Add(Type:=msoControlPopup, before:=1) _
   .Caption = "NewSub"
    ? This displays the shortcut menu bar.
    ' 200, 200 refers to the screen position in pixels as x and y coordinates.
   CommandBars("Cell").ShowPopup 200, 200
End Sub
?????? ???? ??????? ??????? ????? ????? ???? ?? ??? ????? ??? ????? ????? ?????.

????? ???? ???? ??? ?? ????? ????? ?????? ??? ???? ????? ??????

???? ??????? ?????? ??? ????? ????? SubItem1 ??? ??????? ??????? NewSub ???? ??? ???????? ?? ??????? ???????? Cell? ?? ??? ????? ??????? Code_SubItem1 ??? ????? ??? SubItem1:
Sub ShortcutSub_AddItem()
Dim newSubItem as Object
   Set newSubItem = CommandBars("Cell").Controls("NewSub?)
   With newSubItem
      .Controls.Add(Type:=msoControlButton, before:=1).Caption = "subItem1"
      ' This will run the subItem1_Code macro when subItem1 is clicked.
      .Controls("subItem1").OnAction = "Code_subItem1"
   End With
   ' This displays the Cell shortcut menu bar.
   ' 200, 200 refers to the screen position in pixels as x and y coordinates
   CommandBars("Cell").ShowPopup 200, 200
End Sub

????? ???? ???? ????? ????? ????? ?? ????? ??????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ????? SubItem1 ??????? ???????? ??????? NewSub:
Sub ShortcutSub_DisableItem()
   CommandBars("Cell").Controls("NewSub") _
   .Controls("subItem1").Enabled = False
   ' This displays the Cell shortcut menu bar.
   ' 200, 200 refers to the screen position in pixels as x and y coordinates.
   CommandBars("Cell").ShowPopup 200, 200
End Sub
?????? ?????? ???? ????? ?? ?????? ??????? Enabled ??? ?????? True.

??? ???? ???? ????? ????? ????? ?? ????? ??????

???? ?????? ?????? ????? ??? ????? SubItem1 ?? ??????? ??????? NewSub:
Sub ShortcutSub_DeleteItem()
   CommandBars("Cell").Controls("NewSub").Controls("subItem1").Delete
   ' This displays the Cell shortcut menu bar.
   ' 200, 200 refers to the screen position in pixels as x and y coordinates.
   CommandBars("Cell").ShowPopup 200, 200
End Sub

????? ???? ???? ????? ????? ?? ????? ??????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ????? ??????? ??????? NewSub ???????? ????? ??????? ???????? Cell:
Sub ShortcutSub_DisableSub()
   CommandBars("Cell").Controls("NewSub").Enabled = False
   ' This displays the Cell shortcut menu bar.
   ' 200, 200 refers to the screen position in pixels as x and y coordinates.
   CommandBars("Cell").ShowPopup 200, 200
End Sub
?????? ?????? ???? ????? ?? ?????? ??????? Enabled ??? ?????? True.

??? ???? ???? ????? ????? ?? ????? ??????

???? ???????? ???????? ???????? ?? ?????? ?????? ??? ??? ??????? ??????? NewSub ???? ??? ???????? ????? ??????? ???????? Cell:
Sub ShortcutSub_DeleteSub()
   CommandBars("Cell").Controls("NewSub").Delete
   ' This displays the Cell shortcut menu bar.
   ' 200, 200 refers to the screen position in pixels as x and y coordinates.
   CommandBars("Cell").ShowPopup 200, 200
End Sub

?????? ??? ?????? ?? ?????????

????? ??????? ??????? ????? ?????? ?? ????????? ??? ????? ????? ??????? ?????? ??????? ?? Excel.

?????? ????????

????? "?????? ????????" ??? ????? ????? ????? ??????? ????????? ?????? ???? ????. ?????? ??? ??? ?????????? ?? ???????? ??? ???? Visual Basic (???? ALT+F11)? ?? ???? ??? Object Browser ?? ??????? View (?? ???? F2)? ?? ???? ??? ???? ?????? ?? ?????? Search? ?? ???? ????? ENTER ?? ???? ??? Search.

????? ??????? ?? Microsoft

????? "????? ??????? ?? Microsoft" ??? ????? ????????? ???????? ?????? ??????? Microsoft ???????? ??? ????? ??? ?????? Microsoft. ??? ????? ????? ??????? ?? Microsoft ????? ?????? Microsoft. ????? ????? ???????? ??????? ??? ?????? ????? ???????? ???? ??? ?????? Microsoft ?????? ?????????? ??????? ?????? ??????? ??????? ?? ??????? ??????? ???????? ?????? ?????.

??????? ?????? ??????? ?? Microsoft? ?? ?????? ???? Microsoft ?????? ??? ?????? ?? ???? ????????? ???? ???? ?? ??????:
http://support.microsoft.com/?LN=ar

???????

???? ???????: 830502 - ????? ??? ??????: 21/????/1427 - ??????: 4.1
????? ???
  • Microsoft Office Excel 2003
  • Microsoft Excel 2002 Standard Edition
  • Microsoft Excel 2000 Standard Edition
????? ??????: 
kbhowtomaster KB830502

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com