phendrena
05-06-2009, 03:59 AM
Hi,
I'm trying to add the macro "ProtectAll" to my custom commandbar using the following code :
Sub AddButton()
With CommandBars("Personal Toolbar").Controls.Add(Type:=msoControlButton)
.FaceId = 2
.OnAction "ProtectAll"
.Caption "Protect ALL worksheets"
End With
End Sub
The code errors with a compile error 'Invalid Use Of Property' and then highlights the .OnAction line if i comment this out it also fails and highlights .Caption line.
Please help! :help
Thanks,
I'm trying to add the macro "ProtectAll" to my custom commandbar using the following code :
Sub AddButton()
With CommandBars("Personal Toolbar").Controls.Add(Type:=msoControlButton)
.FaceId = 2
.OnAction "ProtectAll"
.Caption "Protect ALL worksheets"
End With
End Sub
The code errors with a compile error 'Invalid Use Of Property' and then highlights the .OnAction line if i comment this out it also fails and highlights .Caption line.
Please help! :help
Thanks,