I am trying to add a button to outlook's tool bar using a Macro.The problem is that the button appears but on clicking it nothing happens,I suspect I am supplying parameters wrongly to the OnAction method.
Call AddToolbarButton("My very own button", "Click here", "!<Sub/UserForm>")
The method it's self:
Function AddToolbarButton(Caption As String, _ toolTip As String, macroName As String, _ Optional toolbarName As String = "Standard", _ Optional FaceID As Long = 325) Dim objBar As Office.CommandBar Dim objButton As Office.CommandBarButton Set objBar = ActiveExplorer.CommandBars(toolbarName) Set objButton = objBar.Controls.add(msoControlButton) With objButton .Caption = Caption .OnAction = macroName .TooltipText = toolTip .FaceID = FaceID .Style = msoButtonIconAndCaption .BeginGroup = True End With End Function
Any help would be highly appreciated.