Disabling Excel Menu Items at Runtime

  • Thread starter Thread starter Prasadtvs
  • Start date Start date
Prasas,

For the commandbar named "BarName" - an example that works.

Sub PartialCBDisable()
Dim i As Integer

With Application.CommandBars("BarName")
For i = 1 To .Controls.Count
.Controls(i).Enabled = False
If i = 2 And Application.UserName = "Bernie Deitrick" Then
.Controls(i).Enabled = True
End If
If .Controls(i).Caption = "&Test" Then
.Controls(i).Enabled = True
End If
Next i
End With

End Sub

HTH,
Bernie
MS Excel MVP
 
Back
Top