Disable custom menu item

G

Guest

How do you disable a custom menu item with VBA? I have several menu items
(pull down type) like File, Edit, and Help etc… I need to disable some of the
items under these menus based upon security level.

Thanks
Mike Robinson
 
G

Guest

Mike

I set the visible property to false. The button is automatically hidden when
you do that.

Two parameters are used: teh index (starting with 1) and a boolean.

Public Function ViewTbarBtn(idx As Long, bolVisible As Boolean)
'Purpose : Hide or show button on tbrPrintRptSnp toolbar.
' Use eTbarIdx for idx value.
' Used mostly to hide Excel button for reports that do not
' convert nicely to a spreadsheet.
'DateTime : 2/4/2005 14:21
'Author : Bill Mosca
Dim tbr As Object
Dim btn As Object

Set tbr = Application.CommandBars("tbrPrintRptSnp")

Set btn = tbr.Controls(idx)

btn.Visible = bolVisible

Set btn = Nothing
Set tbr = Nothing

End Function
 
A

Albert D. Kallal

if IsInGroup(CurrentUser,"SuperUser" then

CommandBars("menu bar").Controls("records").
Controls("refresh").Visible = True

end if


if IsInGroup(CurrentUser(),"InvoideDeleteGroup") = true then

CommandBars("myCustomBar").Controls("AdminOptions").
Controls("DleeteInvoice").Visible = True

end if

Note that short cut menus are their own name also:

commandbars("your shortcut name").
Contorls("contorlName").visiable = false

Note that the first two examples show how to traverse to a sub-menu. And,
you can change visiable to "enabled" if you want to just gray out the menu
item.

Also, I have wrapped the above examples for ease of read, but they go on one
line....
 

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

Top