Sub SetVisibilityExample()
SetControlVisibility "MyMenu", True
SetControlVisibility "MyMenu", False
End Sub
Sub SetControlVisibility(sTag As String, IsVisible As Boolean)
Dim cbc As CommandBarControl
Set cbc = Application.CommandBars.FindControl(, , sTag)
If Not cbc Is Nothing Then
cbc.Visible = IsVisible
End If
Set cbc = Nothing
End Sub
|