Disabling Excel Menu Items at Runtime

  • Thread starter Thread starter Prasadtvs
  • Start date Start date
P

Prasadtvs

I want to Disable few Menu Items at Runtime based on some condition
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top