Our application is currently written using Office XP (Excel 2002). When our tool is run, we modify the menu items (add and remove some of them). For example, we remove some like the ones that allow users to Insert rows. We have code like the following.
With CommandBars(1).FindControl(ID:=30006).CommandBar
.FindControl(ID:=30026).Visible = False
.FindControl(ID:=30024).CommandBar.FindControl(ID:=883).Visible = False
.FindControl(ID:=30024).CommandBar.FindControl(ID:=884).Visible = False
.FindControl(ID:=30025).CommandBar.FindControl(ID:=886).Visible = False
.FindControl(ID:=30025).CommandBar.FindControl(ID:=887).Visible = False
.FindControl(ID:=3058).Visible = False
End With
We also have code to add our own menu items like the following:
Set menBidFile = menGGG.Controls.Add(Type:=msoControlPopup, ID:=1)
menBidFile.Caption = "&Bid File"
menBidFile.TooltipText = "Bid File"
menBidFile.BeginGroup = True
sMenuItemAdd menBidFile, "&New", "Create a new bid file", "ThisWorkbook.sBidNew", False, True And (Range("rngViewOnly") <> "Y"), True
sMenuItemAdd menBidFile, "&Edit", "Edit an existing bid file", "ThisWorkbook.sBidEdit", False, True And (Range("rngViewOnly") <> "Y"), True
sMenuItemAdd menBidFile, "&View", "View an existing bid file", "ThisWorkbook.sBidView", False, True, True
sMenuItemAdd menBidFile, "&Save", "Save the current bid file", "ThisWorkbook.sBidSaveFromMenu", True, True, True
sMenuItemAdd menBidFile, "Save Bid &As", "Save bid file using new name", "ThisWorkbook.sBidSaveAs", False, True, True
sMenuItemAdd menBidFile, "&Close", "Close bid but keep GGG open", "Thisworkbook.sBidClose", True, False, True
menBidFile.Enabled = True
In Excel 2007, is there a way using code to disable/hide some of the options on the ribbons? Also, can we add our own menu items along with ribbon commands? How can this be done using code?
Bookmarks