I am using following code. It creates a macro button on word menu in Add-Ins tab
Public Sub ShowToolbar()
' Assumes toolbar not already loaded '
Application.CommandBars.Add TOOLBARNAME
AddButton "Button caption", "This is a tooltip", 526, "NameOfASubInYourVBACode"
' call AddButton more times for more buttons '
With Application.CommandBars(TOOLBARNAME)
.Visible = True
.Position = msoBarTop
End With
End Sub
Private Sub AddButton(caption As String, tooltip As String, faceId as Long, methodName As String)
Dim Btn As CommandBarButton
Set Btn = Application.CommandBars(TOOLBARNAME).Controls.Add
With Btn
.Style = msoButtonIcon
.FaceId = faceId
.OnAction = methodName
.TooltipText = tooltip
End With
End Sub
I want to assign a recorded macro to created button programatically in vba
I tried a lot but I cant
Can anybody help me
thanks in advance