Consulting

Results 1 to 14 of 14

Thread: Help!!! I've screwed up my Excel!

  1. #1
    VBAX Contributor
    Joined
    Oct 2004
    Location
    Cardiff
    Posts
    120
    Location

    Help!!! I've screwed up my Excel!

    Help!!!

    I modified a macro that disabled copy and paste to disable the edit and tools menus.

    Now it won't reactivate them... What am I doing wrong?

    Option Explicit 
    
    Sub DisableCopyCutAndPaste() 
    EnableControl 30007, False 'tools 
    EnableControl 30003, False 'edit 
    Application.OnKey "^c", "Dummy" 
    Application.OnKey "^v", "Dummy" 
    Application.OnKey "+{DEL}", "Dummy" 
    Application.OnKey "+{INSERT}", "Dummy" 
    Application.CellDragAndDrop = False 
    Application.OnDoubleClick = "Dummy" 
    CommandBars("ToolBar List").Enabled = False 
    End Sub 
    
    Sub EnableCopyCutAndPaste() 
    EnableControl 30007, True 'tools 
    EnableControl 30003, True 'edit 
    Application.OnKey "^c" 
    Application.OnKey "^v" 
    Application.OnKey "+{DEL}" 
    Application.OnKey "+{INSERT}" 
    Application.CellDragAndDrop = True 
    Application.OnDoubleClick = "" 
    CommandBars("ToolBar List").Enabled = True 
    End Sub 
    
    Sub EnableControl(Id As Integer, Enabled As Boolean) 
    Dim CB As Control 
    Dim C As CommandBarControl 
    On Error Resume Next 
    For Each CB In Application.CommandBars 
    Set C = CB.FindControl(Id:=Id, recursive:=True) 
    If Not C Is Nothing Then C.Enabled = Enabled 
    Next 
    End Sub 
    
    Sub Dummy() 
    '// NoGo 
    MsgBox "Sorry, you cannot copy this read-only version of the planner!" 
    End Sub
    Thanks
    You cannot solve all the world's major problems using only potatoes. :- Adams

    http://www.vbaexpress.com

  2. #2
    VBAX Mentor CBrine's Avatar
    Joined
    Jun 2004
    Location
    Toronto, Canada
    Posts
    387
    Location
    Tamer,

    Give this code a try. Depending on where you locked up the menu, it might work.


    Sub FixMenu()
    Application.CommandBars("File").Enabled = True
    Application.CommandBars("Edit").Enabled = True
    Application.CommandBars("View").Enabled = True
    Application.CommandBars("Worksheet Menu Bar").Controls("Insert").Enabled = True
    Application.CommandBars("Format").Enabled = True
    Application.CommandBars("Tools").Enabled = True
    Application.CommandBars("Data").Enabled = True
    Application.CommandBars("Window").Enabled = True
    Application.CommandBars("Help").Enabled = True
    End Sub
    The most difficult errors to resolve are the one's you know you didn't make.


  3. #3
    VBAX Mentor CBrine's Avatar
    Joined
    Jun 2004
    Location
    Toronto, Canada
    Posts
    387
    Location
    To set your sheet to no COPY give this code a try. I will stop all copy and paste. Combined with Workbook protection to prevent a right click on the sheet tab copy, they will not be able to copy at all.

    HTH
    Cal


    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    Application.CutCopyMode = False
    End Sub
    The most difficult errors to resolve are the one's you know you didn't make.


  4. #4
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Quote Originally Posted by CBrine
    ... they will not be able to copy at all.
    Unless they disable macros.

  5. #5
    VBAX Contributor
    Joined
    Oct 2004
    Location
    Cardiff
    Posts
    120
    Location
    I've used the veryHidden solution to the disabling of macros - secure enough for my needs here.

    Thanks all again!
    You cannot solve all the world's major problems using only potatoes. :- Adams

    http://www.vbaexpress.com

  6. #6
    VBAX Mentor CBrine's Avatar
    Joined
    Jun 2004
    Location
    Toronto, Canada
    Posts
    387
    Location
    True enough Zack.

    I fogot to include, that when I use this, I remove the toolbars, the commandmenus, have a worksheet password, have a workbook password and make all sheets xlveryhidden as well. So they can't really get into my sheets without the macro's enabled.
    The most difficult errors to resolve are the one's you know you didn't make.


  7. #7
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Quote Originally Posted by CBrine
    True enough Zack.

    I fogot to include, that when I use this, I remove the toolbars, the commandmenus, have a worksheet password, have a workbook password and make all sheets xlveryhidden as well. So they can't really get into my sheets without the macro's enabled.
    :rofl I love it!

  8. #8
    VBAX Mentor CBrine's Avatar
    Joined
    Jun 2004
    Location
    Toronto, Canada
    Posts
    387
    Location
    I thought about hiring a big muscular guy to go around to each of my spreadsheet users, and slap them in the side of the head each time they tried to do something they weren't supposed to. That might be going to far though.
    The most difficult errors to resolve are the one's you know you didn't make.


  9. #9
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Quote Originally Posted by CBrine
    I thought about hiring a big muscular guy to go around to each of my spreadsheet users, and slap them in the side of the head each time they tried to do something they weren't supposed to. That might be going to far though.
    :rofl Same thought has occured to me on occasions! (We don't have the budget though! :no )
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  10. #10
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Quis Custodiet Ipsos Custodes?

  11. #11
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    So, Tamer, did you get the original query resolved? We kinda sidetracked your thread here. Sorry!

  12. #12
    VBAX Contributor
    Joined
    Oct 2004
    Location
    Cardiff
    Posts
    120
    Location
    Well I guess they're all good suggestions in their own ways.
    Actually, in spite pf my panic, what i'd done was quite simple - i just didn't realise it.
    I have code from DRJ and IVAN that disables copy on the read-only version. but i amended it and tested it on the write version. but the code to put the menus back also only worked on the write version! and i was just blind.

    The problem on my s/s isn't sensetivity, but deletion and sabotage. important s/shts kept on reverting to older versions, and we'd lose tons of info. So now you can't open without macros (xlVeryHidden) . you can't do any copying on the read-only version. Save and SaveAs are also disabled, and sheets can't be dragged and copied.
    Also, two backups are recorded in secret locations with the date and time being recorded as the file name.

    Its secure enough for amatures.

    anyhows, thanks again guys.
    Tamer
    You cannot solve all the world's major problems using only potatoes. :- Adams

    http://www.vbaexpress.com

  13. #13
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Cool! So should this be marked Solved then?

  14. #14
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Quote Originally Posted by CBrine
    I thought about hiring a big muscular guy to go around to each of my spreadsheet users, and slap them in the side of the head each time they tried to do something they weren't supposed to. That might be going to far though.
    :rofl I would do that, but I would go broke with all the work I would be sending his way.

Posting Permissions

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