Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
New at VB. Need to delete Insert Worksheet from file menu at open and reset
at close. I got this code from MS site. Doesn't reset at close unless I hit the F5 key. Sub menuItem_Delete() Dim myCmd As Object Set myCmd = CommandBars("Worksheet menu bar").Controls("Insert") myCmd.Controls("Worksheet").Delete End Sub Sub MenuBar_Restore() CommandBars("Insert").Reset End Sub Any help will be appreciated much. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
First, I wouldn't use Reset - what if the user has other customizations?
I think you want to make the control not visible Private Sub workbook_Open() Dim myCmd As Object Set myCmd = CommandBars("Worksheet menu bar").Controls("Insert") myCmd.Controls("Worksheet").Visible = False End Sub Private sub workbook_BeforeClose() Dim myCmd As Object Set myCmd = CommandBars("Worksheet menu bar").Controls("Insert") myCmd.Controls("Worksheet").Visible = True End sub this code would need to be in the ThisWorkbook module. For information on Events, see Chip Pearson's site http://www.cpearson.com/excel/events.htm all that said, it might be better just to protect the structure of your workbook (Tools=Protect=Protect Workbook) that would disallow the insertion or deletion of worksheets. -- Regards, Tom Ogilvy "Jane" wrote: New at VB. Need to delete Insert Worksheet from file menu at open and reset at close. I got this code from MS site. Doesn't reset at close unless I hit the F5 key. Sub menuItem_Delete() Dim myCmd As Object Set myCmd = CommandBars("Worksheet menu bar").Controls("Insert") myCmd.Controls("Worksheet").Delete End Sub Sub MenuBar_Restore() CommandBars("Insert").Reset End Sub Any help will be appreciated much. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Unable to delete or insert a worksheet. | Excel Discussion (Misc queries) | |||
How do I close excell worksheet without closing others still open | Excel Worksheet Functions | |||
How can I use open/close Grouped cells in a Protected Worksheet? | Excel Discussion (Misc queries) | |||
Delete/Close Excel file that is kept OPEN | New Users to Excel | |||
Loop thru files in DIR, delete worksheets & reset worksheet Name property?? | Excel Programming |