tags:

views:

601

answers:

0

I have disabled "cut" in my excel and have changed paste to paste-special (values) only in my function called "stoppaste". I have written this code in Workbook_Activate, Workbook_SheetActivate. The code is given below:

Application.CellDragAndDrop = False Application.CommandBars("Edit").Controls("Paste").Enabled = False Application.CommandBars("Edit").Controls("Paste Special...").Enabled = False Application.CommandBars("Cell").Enabled = False Application.OnKey "^v", "stoppaste1" Application.OnKey "^+V", "stoppaste1" Application.OnKey "{ENTER}", "stoppaste2" Application.OnKey "~", "stoppaste3" Application.OnKey "^x", "" Application.OnKey "^+X", "" Application.CutCopyMode = False

I then enable cut, copy and paste by resetting it in Workbook_Deactivate and Workbook_SheetDeactivate. The code is given below:

Application.CellDragAndDrop = True Application.CommandBars("Edit").Controls("Paste").Enabled = True Application.CommandBars("Edit").Controls("Paste Special...").Enabled = True Application.CommandBars("Cell").Enabled = True Application.OnKey "^v" Application.OnKey "^+V" Application.OnKey "{ENTER}" Application.OnKey "~" Application.OnKey "^x" Application.OnKey "^+X" Application.CutCopyMode = True

When I toggle from my excel to another and copy (control-c) a value from the second excel and toggle back to my excel to paste it, it does not paste the value. This is a problem for me.

On the other hand, if I remove the code in Workbook_Activate and Workbook_Deactivate but retain the Workbook_SheetActivate and Workbook_SheetDeactive functions, copy from the second excel into my excel works fine, but the cut function in the second excel gets disabled. This becomes a problem for others who use my my excel.

What do I need to do such that copy-paste works in my excel as I have defined it, while all excel functions work as usual in the user's second workbook?