+ Reply to Thread
Results 1 to 11 of 11

Code to stop cut copy paste and other keys

  1. #1
    Forum Contributor
    Join Date
    09-27-2017
    Location
    USA
    MS-Off Ver
    MS365 - 2302
    Posts
    163

    Lightbulb Code to stop cut copy paste and other keys

    Hi All,

    I have been using this below code to stop cut copy paste and other functions but for some reason I am not sure if someone changed something in the code but I am having troubles.

    I dont want users to be able to use the below functions

    CUT, COPY, PASTE, INSERT, F2 (FUNCTION KEY) ,DELETE OR SPACE BAR KEY.

    The problem i am facing is that any workbook thats opened also starts being effected by it. I am unable to use any functions in any other file open can someone please take a look at this code much appreciated

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Code to stop cut copy paste and other keys

    Hi there,

    Try inserting the following code in the "ThisWorkbook" VBA CodeModule (i.e. NOT in a standard VBA CodeModule):

    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  3. #3
    Forum Contributor
    Join Date
    09-27-2017
    Location
    USA
    MS-Off Ver
    MS365 - 2302
    Posts
    163

    Re: Code to stop cut copy paste and other keys

    Please Login or Register  to view this content.
    HI the above code is already in this work book, should i be replacing it?

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Code to stop cut copy paste and other keys

    Hi again,

    Oops, my bad! I should have included the code for the Workbook_Open and Workbook_BeforeClose events also

    It appears that your code SHOULD work correctly - are you sure that the code mentioned is entered in the "ThisWorkbook" VBA CodeModule? Itwon't work if it's inserted in a standard CodeModule.

    If the problem persists, can you post even a partial copy of your workbook here? We don't really need the contents of the worksheets, just the VBA.

    Regards,

    Greg M

  5. #5
    Forum Contributor
    Join Date
    09-27-2017
    Location
    USA
    MS-Off Ver
    MS365 - 2302
    Posts
    163

    Re: Code to stop cut copy paste and other keys

    Hi Greg,

    I am still able to use the delete option in the work book which should be disabled and F2 key as well. And when i have this book open I am unable to use cut copy paste in another open excel

    here is a copy of the sheet.
    Attached Files Attached Files

  6. #6
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Code to stop cut copy paste and other keys

    Hi again,

    See if the attached version of your workbook does what you need. I've highlighted the changes/additions I made to your code:

    Please Login or Register  to view this content.

    Switching to another workbook re-enables all of the features disabled by the above code, and returning to this workbook disables them once again.


    If you need to really "tie the User's hands" I think you'll need to check the various other keyboard shortcuts which exist, and disable them also. For example, using Ctrl with the plus/minus keys allows the User to insert/delete a row.


    Hope this helps - as before, please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    09-27-2017
    Location
    USA
    MS-Off Ver
    MS365 - 2302
    Posts
    163

    Re: Code to stop cut copy paste and other keys

    HI Greg,

    Now I am getting


    Please Login or Register  to view this content.
    Sub or function not defined

  8. #8
    Forum Contributor
    Join Date
    09-27-2017
    Location
    USA
    MS-Off Ver
    MS365 - 2302
    Posts
    163

    Re: Code to stop cut copy paste and other keys

    Call EnableMenuItem(21, Allow) ' cut

  9. #9
    Forum Contributor
    Join Date
    09-27-2017
    Location
    USA
    MS-Off Ver
    MS365 - 2302
    Posts
    163

    Re: Code to stop cut copy paste and other keys

    HI I was able to solve the above,

    However I tried including this
    Please Login or Register  to view this content.
    To stop backspace but it still works how to I stop that?

  10. #10
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Code to stop cut copy paste and other keys

    Hi again,

    Try using:

    Please Login or Register  to view this content.

    Hope this helps - as before, please let me know how you get on.

    Regards,

    Greg M

  11. #11
    Forum Contributor
    Join Date
    09-27-2017
    Location
    USA
    MS-Off Ver
    MS365 - 2302
    Posts
    163

    Re: Code to stop cut copy paste and other keys

    Quote Originally Posted by Greg M View Post
    Hi again,

    Try using:

    Please Login or Register  to view this content.

    Hope this helps - as before, please let me know how you get on.

    Regards,

    Greg M
    Thank you this works sorry i was away for a long time

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA to copy/paste down values and stop at row with text
    By lukestkd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-26-2015, 07:11 AM
  2. Keys to copy paste formula vba
    By keen2xl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2014, 03:50 PM
  3. [SOLVED] how to copy& paste special value and stop when find cell with zero value
    By Khaled Diab in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-01-2014, 06:18 AM
  4. Stop overwriting cells - Copy and paste macro
    By juhaszp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-25-2013, 05:37 PM
  5. [SOLVED] Cut, Copy or Paste causes excel to stop responding.
    By Jimizx in forum Excel General
    Replies: 2
    Last Post: 10-19-2012, 09:43 PM
  6. Stop users from Cut/Copy & Paste
    By rmcveigh in forum Excel General
    Replies: 2
    Last Post: 11-21-2006, 04:09 PM
  7. How to stop formulas from incrementing when you copy and paste?
    By Kirkwill in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-28-2005, 02:06 PM

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