Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom MenuBar problem

Status
Not open for further replies.

GreenFella

Programmer
Oct 23, 2001
41
CA
Hi

I am attempting to disable certain menubar items depending upon the security level of a user. However, I am having problems referencing the menubar item to disable them.

I have been able to do this to the main menubar but have not been able to do so to sub menu bar items.

Not to sure if I am using the right verbage here but this is an example of what I want to be able to do.

Inventory
Add Inventory
Delete Inventory
Print Inventory

I would like to be able to allow most users the ability to print the inventory but not add to inventory or delete from inventory.

So, I want to disble the Add Inventory and Delete Inventory items from the sub menu.

Any thoughts would be appreciated.

Thanks
Greenfella
 
Hi Greenfella,

Any luck with this? I've come across the same problem, although I don't need to disable items based on security, but rather when a specific event happens.
 
The syntax would be:
CommandBars("<menu bar name>").Controls("Inventory").Controls("Add Inventory").Enabled = False

If you're doing multiple controls at the same time, you might want to use more efficient code:
Code:
    Dim cbr As Office.CommandBar
    Dim cbp As Office.CommandBarPopup

    Set cbr = CommandBars("<menu bar name>")
    Set cbp = cbr.Controls("Inventory")
    With cbp
        .Controls("Add Inventory").Enabled = False
        .Controls("Delete Invetory").Enabled = False
    End With

GreenFella: Sorry you were overlooked in April last year. But you still have the thread marked for notification--you must be quite a PatientFella! :)

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
I almost fell over when I got these responses.

Thanks for the link nimarii.

Thanks for the example RickSpr. I'm going to have to put that in my code samples book.

I eventually did figure something out for this problem although not nearly as elegant.

Thanks again.
Greenfella
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top