Can u add tool bar to microsoft word

vba Pakistan
  • 18 years ago

    if not try this.


    1. Open visual Basic editor from Microsoft word from tools macros
    Add following code in it



    Dim CmdBarEvents As New Class1


    Sub Macro1()


       
         Dim cmbNewBar As CommandBar
       Dim ctlBtn As CommandBarButton


       Set cmbNewBar = Application.CommandBars.Add
       cmbNewBar.Name = "New Tool Bar Name"
       With cmbNewBar
           Set ctlBtn = .Controls.Add(msoControlButton)
           With ctlBtn
               .Style = msoButtonIconAndCaption
               .BeginGroup = True
               .Caption = "&New Button"
               .TooltipText = "Tool Tip Text For new Button"
               .FaceId = 65
            Set CmdBarEvents.BtnCtrl = ctlBtn
           End With
           .Protection = msoBarNoCustomize
           .Position = msoBarTop
           .Visible = True
       End With


    End Sub



    Add a new class with name Class1 (default name)


    Add following code in it



    Public WithEvents BtnCtrl As Office.CommandBarButton


    Private Sub BtnCtrl_Click(ByVal Ctrl As _
       Office.CommandBarButton, CancelDefault As Boolean)
       MsgBox Ctrl.Caption & " was clicked"
    End Sub



    For further in formations please contact me at
    [email protected]
    or
    [email protected]

  • 18 years ago

    Would you like this published properly on Developer Fusion? If so, you can submit it via http://www.developerfusion.com/private/submit.aspx

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Brevity is the soul of wit” - Shakespeare