HOW TO: ????? ????? ???? ? ????? ?????? ?????? ?? CommandBar 2003 Office

?????? ????????? ?????? ?????????
???? ???????: 824017 - ??? ???????? ???? ????? ????? ??? ???????.
??? ????? ??? ???????. ????? "??? ??" ??? ??? ??????? ??? ????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ???? ????? ??? ????? ????? ???? ?????? ???? ???? ???? Microsoft Office 2003 CommandBar ?? ???? ??????? ?????? ??? ??????? ???? ?? ?????? ???????? ????? Visual Studio ??? ???? Microsoft Office. ????? ???? ???? ?? ?????? ?????? ???? ???? ??? ???? ???? CommandBar. ?? ??? ??????? ????? ???? ?????? ????? ????? ???? ??????.


????? ???? ????? Visual Basic .NET Excel ????

  1. ?? ??????? ??? ?? Microsoft Visual Studio .NET 2003 ??? ??? ???? ?? ???? ??? ???????.

    ???? ???? ?????? ????? ????.
    1. ?? ??????? ????? Project ????? ??????? ???? Microsoft Office ? ?? ???? ??? ?????? Visual Basic.
    2. ?? ????? ????? ???? ??? ???? Excel.
    3. ?? ?????? ?????? ???? ExcelCommandbar ??? ?? ???? ??? ?????.

      ???? ????? Microsoft Office Project.
    4. ???? ??? ?????.
  2. ?? ??????? ??????? ???? ??? ????? ????.

    ???? ???? ?????? ????? ??????.
    1. ???? ??? ????? ??????? .NET. ?? ????? ???????? ???? ??? System.Drawing.dll ?? ???? ??? ?????.
    2. ?? ????? ???????? ???? ??? stdole ?? ???? ??? ?????.
    3. ???? ??? ?????.
  3. ????? ????? ??????? ?? ???? ThisWorkbook.vb:
    Imports System.Reflection

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

?? ??? ?????? ??? ????? ?????? ?????? ??????? ??? ???????. ???? ???? ????? ???? ???? ?????? CommandBar. ???? ???? ??????? ????.

????? ????? ???? ??? ????? ????????? ???? ???? ???? ???? ?????? CommandBar
  1. ?? ??????? ??????? ???? ??? ????? ????????. ???? ???? ?????? ????? ???? ????.
  2. ?? ????? ????? ???? ??? ??? ?????? ???????.
  3. ??? ?????? Picture.bmp ?? ???? ??? ???.

    ??? ??? ?????? ??????? ??????? ?? ???? ????? ???????.
  4. ?? ??????? ???? ???? ??? ???? ?????. ????? ??????? ??? ?? "?" ??????? ?????? ?????? ??????? ??? 16.
  5. ????? ????? ?????? ??????? ??????? ?????? ?? ?? ???? ????? ????? ?? ??? ?????? ???????.
  6. ?? "?????? ??????" ???? ??? ?????? ?????? ??? Picture.bmp ??? ?? ???? ??? ?????. ????? ??????? ????? ????? ??? ??????? ???????.
  7. ?? ??????? ???? ???? ??? ??? Picture.bmp.
????? ????? ???? ??? ????? ????????? ???? ???? ???? ???? ???? ?????? CommandBar
  1. ?? "?????? ??????" ???? ??? Picture.bmp.
  2. ?? ??????? ???? ???? ??? ???.
  3. ?? ??????? ???? ???? ??? ???.

    ????? ??? ???? ???? ????? ??? Picture.bmp ??? ???????.
  4. ?? "?????? ??????" ???? ??? ?????? ?????? ??? Mask.bmp ??? ?? ???? ??? ????? ???????. ?? ?????? ????? Mask.bmp.
  5. ?? "?????? ??????" ???? ??? ?????? ?????? ??? Mask.bmp ??? ?? ???? ??? ???. ????? ??? ??????? ?????? ????? ?????? ?????? ??? ??????? ??? ??????.

    ?????? ??? ????? ?????? ?? ?????? ??? ???? ???? CommandBar ????? ????? ?????? ?????. ????? ???? ????.
  6. ?? ??????? ???? ???? ??? ??? Mask.bmp.

????? ??? ??? ????? CommandBar ??????? CommandBar

?? ??? ?????? ????? ?????? ?????? ??? ????? ???? ????? ??????? ?????? ??????? ?? ?????? ???? ??? CommandBar ??????? CommandBar ?? ????? ????? ???? ?????? ???? ????? ?????? CommandBar.
  1. ????? ????? ??????? ??? ????? ????? ??? ??? OfficeCodeBehind:
    WithEvents CBarButton As Office.CommandBarButton
  2. ????? ????????? ???????? ??????? ??? ????? ??????? ThisWorkbook_Open ?? ThisWorkbook.vb:
        'Get a reference to this assembly.
        Dim ThisAssembly As [Assembly]
        ThisAssembly = [Assembly].GetExecutingAssembly()
    
        'Load the Picture and the Mask image resources.
        Dim imgStreamPic As System.IO.Stream, imgStreamMask As System.IO.Stream
        imgStreamPic = ThisAssembly.GetManifestResourceStream("ExcelCommandBar.Picture.bmp")
        imgStreamMask = ThisAssembly.GetManifestResourceStream("ExcelCommandBar.Mask.bmp")
    
        'Obtain references to IPictureDisp for both images.
        Dim ax As New MyAxHost
        Dim Pic As stdole.IPictureDisp, Mask As stdole.IPictureDisp
        Pic = ax.IPictureDisp(Drawing.Image.FromStream(imgStreamPic))
        Mask = ax.IPictureDisp(Drawing.Image.FromStream(imgStreamMask))
    
        'Add a temporary CommandBar and a CommandBar button.
        Dim CBar As Office.CommandBar
        CBar = ThisApplication.CommandBars.Add("My CommandBar", , , True)
        CBarButton = CType(CBar.Controls.Add(Office.MsoControlType.msoControlButton), _
                    Office.CommandBarButton)
        CBarButton.Style = Office.MsoButtonStyle.msoButtonIconAndCaption
        CBarButton.Caption = "My Button"
        CBarButton.Tag = "My_Button"
        CBarButton.Picture = Pic
        CBarButton.Mask = Mask
        CBar.Visible = True
    
    
  3. ????? ??? ??????? MyAxHost ?????? ??? ????? ??????? ThisWorkbook_Open ?? ThisWorkbook.vb:
    Public Class MyAxHost
    
        Inherits System.Windows.Forms.AxHost
    
        Public Sub New()
            MyBase.New("59EE46BA-677D-4d20-BF10-8D8067CB8B33")
        End Sub
    
        Public Shared Function IPictureDisp(ByVal Image As System.Drawing.Image) As stdole.IPictureDisp
            IPictureDisp = CType(AxHost.GetIPictureDispFromPicture(Image), stdole.IPictureDisp)
        End Function
    
    End Class
  4. ????? ???? ??????? ??? ????? OfficeCodeBehind:
    Private Sub CBarButton_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton,  _
        ByRef CancelDefault As Boolean) Handles CBarButton.Click
        MessageBox.Show("You clicked My Button!")
    End Sub
  5. ???? F5 ?????? ? ?????? ???????.

    ???? ?? ExcelCommandBar.xls ??? ?? Excel. ??? ??? ?????? ???? CommandBar ????. ????? CommandBar ???? ?????? CommandButton ???? ?? ???? ?????.


?????

?????? ??? ??????? ??????? ???? ??? ??? ??????? ?????? ?????? ?? "????? ??????? ?? Microsoft:
286460HOWTO: ????? "????" ? "????? ?????? ?? Office XP CommandBars

???????

???? ???????: 824017 - ????? ??? ??????: 28/???? ??????/1435 - ??????: 2.4
????? ???
  • Microsoft Office Excel 2003
  • Microsoft Office Word 2003
  • Microsoft Visual Studio Tools for the Microsoft Office System
????? ??????: 
kbnosurvey kbarchive kbmt kbhowtomaster kbpia KB824017 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????824017

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