+ Reply to Thread
Results 1 to 2 of 2

Delete Insert Worksheet on Open/Reset on Close

  1. #1
    Jane
    Guest

    Delete Insert Worksheet on Open/Reset on Close

    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. #2
    Tom Ogilvy
    Guest

    RE: Delete Insert Worksheet on Open/Reset on Close

    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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1