I am looking for VBA code to search the Standard toolbar for a Save button and if it is found to delete it. I also need to search the File menu for the Save command and if it is found there, then delete it. Can anyone help?
I tried using this code, that I use in Excel, but it deletes both the Save button and the Save As button. Am I on the right track?
Sub RemoveItemFromToolbar(strTBName As String, _
strButtonName As String)
Dim cbarMenu As CommandBars
Dim cctlControl As CommandBarControl
‘ Grab the application CommandBars object.
Set cbarToolsMenu = Application.CommandBars
‘ DELETE: Toolbar button.
‘ Loop through the CommandBars.
For Each cctlControl In cbarToolsMenu(strTBName).Controls
With cctlControl
‘ Check to see if the toolbar is found.
If .Caption = strButtonName Then
‘ If found, remove the command from the menu.
.Delete
End If
End With
Next cctlControl
End Sub
Then I call it like this:
CommandBars(“Standard”).Reset
RemoveItemFromToolbar “Standard”, “Save”