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]
Enter your message below
Sign in or Join us (it's free).