disable new and open menu icons


Posted by Jim on December 11, 2001 12:08 PM

Hello group,
I'm trying to set up a menu in a particular workbook
that will prevent the end user from messing things up
while the file is open. I ultimately need on workbook_
Open()to disable the "new" and "open" icons. Does anyone
have a clue.
Thanks, Jim



Posted by Jacob on December 11, 2001 2:15 PM

This will do the trick

Hi
This should do the trick.

Private Sub Workbook_Activate()
Dim MyCommand As CommandBar
Set MyCommand = Application.CommandBars("Worksheet Menu bar")

With MyCommand
.Controls("&File").Controls("&New...").Enabled = False
.Controls("&File").Controls("&Open...").Enabled = False

End With
Set MyCommand = Application.CommandBars("Standard")

With MyCommand
.Controls("&New").Enabled = False
.Controls("&Open").Enabled = False


End With

End Sub


Private Sub Workbook_Deactivate()
Dim MyCommand As CommandBar
Set MyCommand = Application.CommandBars("Worksheet Menu bar")

With MyCommand
.Controls("&File").Controls("&New...").Enabled = True
.Controls("&File").Controls("&Open...").Enabled = True

End With
Set MyCommand = Application.CommandBars("Standard")

With MyCommand
.Controls("&New").Enabled = True
.Controls("&Open").Enabled = True


End With

End Sub


Also you will need to deactivate the ctrl O and ctrl N hot keys. For this just make a macro and assign O and N as the keyboard shortcut. You dont need to put any code in the macro, but this will make the hotkey run the macro instead of opening or making a new File.

Hope this helps.

Jacob