I have created a sub routine that creates a command bar with one button. The code is located in the modules directory of my project. I am trying to call a public sub routine from a class module called SinkObject. SinkObject is the only class module located under the Class Modules directory. I am using the onAction method to call the sub. Word is giving me the error "The macro cannot be found or has been disabled because of macro security. Is this possible? am I doing this wrong?
Thanks for the help. Here is the code.
Public Sub iManageFooterCommandbar()
Dim objCommandBar As Office.CommandBar
Dim objCommandBarControl As Office.CommandBarControl
Dim objCommandBarButton As Office.CommandBarButton
For Each objCommandBar In Application.CommandBars
If objCommandBar.Name = "iManage Footer" Then
objCommandBar.Delete
End If
Next objCommandBar
Set objCommandBar = Application.CommandBars.Add _
("iManage Footer"
With objCommandBar.Controls
Set objCommandBarButton = .Add(msoControlButton)
With objCommandBarButton
.Caption = "iManag&e Footer"
.FaceId = 59
.Style = msoButtonIconAndCaption
.TooltipText = _
"Click here to insert iManage Footer."
End With
'The line below is where I believe the problem is occuring.
objCommandBarButton.OnActive = "SinkObject.ApplyFooter"
End With
objCommandBar.Visible = True
End Sub
Thanks for the help. Here is the code.
Public Sub iManageFooterCommandbar()
Dim objCommandBar As Office.CommandBar
Dim objCommandBarControl As Office.CommandBarControl
Dim objCommandBarButton As Office.CommandBarButton
For Each objCommandBar In Application.CommandBars
If objCommandBar.Name = "iManage Footer" Then
objCommandBar.Delete
End If
Next objCommandBar
Set objCommandBar = Application.CommandBars.Add _
("iManage Footer"
With objCommandBar.Controls
Set objCommandBarButton = .Add(msoControlButton)
With objCommandBarButton
.Caption = "iManag&e Footer"
.FaceId = 59
.Style = msoButtonIconAndCaption
.TooltipText = _
"Click here to insert iManage Footer."
End With
'The line below is where I believe the problem is occuring.
objCommandBarButton.OnActive = "SinkObject.ApplyFooter"
End With
objCommandBar.Visible = True
End Sub