Not quite what I'm looking for, terry, I've already made my own menu and disabled the regular menues....what I'm looking for, is a way to disable one of menu-items in my menu, using VBA, based on a value that's stored in the database (The menu-item disables edits in the database and I want that menu-item to "disaper" afterwards. Once it's been made "un-editable", I don't want users to be able to make it editable)
MenuIndex Required Variant. An integer, counting from 0, that's the valid index of a menu on the custom menu bar or global menu bar for the active window, as defined in the menu bar macro for the custom menu bar or global menu bar. If you select a menu with this argument and leave the commandindex and subcommandindex arguments blank (or set them to –1), you can enable or disable the menu name itself. You can't, however, check or uncheck a menu name (Microsoft Access ignores the acMenuCheck and acMenuUncheck settings for the flag argument for menu names).
CommandIndex Optional Variant. An integer, counting from 0, that's the valid index of a command on the menu selected by the menuindex argument, as defined in the macro group that defines the selected menu for the custom menu bar or global menu bar for the active window.
SubcommandIndex Optional Variant. An integer, counting from 0, that's the valid index of a subcommand in the submenu selected by the commandindex argument, as defined in the macro group that defines the selected submenu for the custom menu bar or global menu bar for the active window.
Følgende kode har jeg rodet med på et tidspunkt da jeg også legede med menuer. Det virkede delvist.
Dim cbr As CommandBar Dim cbrCtl As CommandBarPopup
Set cbr = CommandBars("Hovedmenu") cbr.Protection = msoBarNoResize + msoBarNoChangeDock + msoBarNoCustomize + msoBarNoChangeVisible + msoBarNoMove On Error Resume Next If cbr.Visible = False Then cbr.Visible = True With cbr Cbr.Controls.Item("Hovedmenu_Maint").Visible = False Set cbrCtl = .Controls("Vedligehold") .Add(msoControlButton) With cbrCtl .Controls("Brugerrettigheder").Visible = False End With End With
Her er noget der virker, sådan da, det virker på den indbyggede menu, men hvordan får jeg den til at virke på MIN menu? menuen hedder LabReg og menupunktet jeg vil have til at "grey-out" hedder Make system read-only
Set cbc = CommandBars("Menu Bar").Controls("Rediger").CommandBar.Controls("Fortryd indtastning")
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.