Closed Thread
Results 1 to 11 of 11

Disabled "Delete" for one workbook turned out to be applied to every workbook...

  1. #1
    Registered User
    Join Date
    06-27-2009
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    10

    Exclamation Disabled "Delete" for one workbook turned out to be applied to every workbook...

    Good morning everyone ,

    I had coffee yesterday evening and could not sleep early so I worked on some spreadsheets...

    I wanted to disable the function "Delete" when right-clicking on worksheets.

    I copy paste the following VBA code in every sheet code :


    Please Login or Register  to view this content.
    It worked fine. Then I opened another project workbook to work on it and guess what, the function delete was also disabled !

    So I went back to the previous workbook and deleted from every sheet code the previous code. But it did not work and for every Excel workbook I opened, when I right-clicked on a sheet, the function "delete" is disabled...

    so here I am, panicking, I really don't know what to do. So I am here this morning and last night sleep didn't help me to solve this problem.

    Does anyone have a clue to help me ? Do you think an uninstall and new install might solve this problem ??

    I am really helpless

    Susie
    Last edited by susie86; 07-13-2009 at 04:31 PM.

  2. #2
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Disabled "Delete" for one workbook turned out to be applied to every workbook...

    You adjusted an Application.CommandBars item, hence it is adjusted at APPLICATION level.

    To reinstate it you just need to change your 'FALSE' to 'TRUE'.

    You can either alter it in your original workbook, or else open a new workbook, and insert this code into a new module, then run it:

    Please Login or Register  to view this content.
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

  3. #3
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Disabled "Delete" for one workbook turned out to be applied to every workbook...

    Incidentally, in the workbook you were trying to disable the 'Delete' for, place the following code into the 'ThisWorkBook' section of the VB Editor:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    That will then disable the delete command whenever that workbook is active, and re-enable the delete command whenever that workbook is not active

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Disabled "Delete" for one workbook turned out to be applied to every workbook...

    FWIW, you could simplify a bit:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  5. #5
    Registered User
    Join Date
    06-27-2009
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Disabled "Delete" for one workbook turned out to be applied to every workbook...

    You are both awesome
    I really thought I was in trouble

    Is there any way to also disable the "rename" function ?

    I tried the following code in each sheet :

    Please Login or Register  to view this content.
    It allowed renaming sheet but when going to another sheet, excel renamed it back to the original name. However, this method messes up with the hyperlink I have implemented in the sheet.

    It would be better to have it disable like the "delete" function.

    Thanks

    Susie
    Last edited by susie86; 07-13-2009 at 04:30 PM.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Disabled "Delete" for one workbook turned out to be applied to every workbook...

    Susie,

    Please edit your post to add code tags.
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Registered User
    Join Date
    06-27-2009
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Disabled "Delete" for one workbook turned out to be applied to every workbook...

    to shg:

    it is done, I spent 15min wondering how to do it

  8. #8
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Disabled "Delete" for one workbook turned out to be applied to every workbook...

    Hi Susie,

    This will disable the 'Rename' command on the tab right-click menu:
    Please Login or Register  to view this content.
    Change back to TRUE and run the code to re-enable the command.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Disabled "Delete" for one workbook turned out to be applied to every workbook...

    it is done, I spent 15min wondering how to do it
    The forum rules are a fount of useful information, including that. I commend them to your reading

  10. #10
    Registered User
    Join Date
    07-31-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Disabled "Delete" for one workbook turned out to be applied to every workbook...

    Hi,

    I opened a new workbook and copiend the below code to enable the Delete Sheet button, but still i ma not able to delete any of the seets from other excels. When i tried deleting a sheet from another sheet it is displaying security warning to enable/disable marcro . On click of Enable Macro it is opening the old work book in which i copied the delete sheet code. (Note: I deleted entire code but again it is displaying macro...... not found)

    Please help me to over come this BIG BIG problem.



    Sub Fix_It()
    Dim CommBarTmp, Commbar As CommandBar

    For Each Commbar In Application.CommandBars
    Set CommBarTmp = Commbar.FindControl(ID:=847, recursive:=True)
    If Not CommBarTmp Is Nothing Then CommBarTmp.Enabled = True
    Next
    End Sub

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Disabled "Delete" for one workbook turned out to be applied to every workbook...

    Please take a few minutes to read the forum rules, start your own thread, and use code tags around code.

Closed 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