Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable Cntrl_C and Cntrl_V in VBA
I have been very kindly given the code to disable the right mouse butto
in a spreadsheet I am creating. I have found that if I create a new macro in this workbook and assig Ctrl_C to it, but then leave the macro blank, this does what I want but If I open another workbook at the same time, Ctrl_C remain disabled until I close the workbook that contains the blank macro. I would like to know if there is a way to disable the Ctrl_C and Ctrl_ shortcuts in this workbook only, but allow them to work in other ope workbooks. Is this possible? thanks Celtic_Avenger :confused -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable Cntrl_C and Cntrl_V in VBA
Hi Celtic_Avenger,
I would like to know if there is a way to disable the Ctrl_C and Ctrl_V shortcuts in this workbook only, but allow them to work in other open workbooks. Sure. You need to hook the workbook's events and disable them when one of the workbook's windows is activated and enable them when one of the workbook's windows is deactivated. I guess you also need to handle Shift+Insert and Ctrl+Insert as well. Put the following in the ThisWorkbook module: Private Sub Workbook_WindowActivate(ByVal Wn As Window) 'Disable when switching to us Application.OnKey "^C", "" Application.OnKey "^c", "" Application.OnKey "^{INSERT}", "" Application.OnKey "^V", "" Application.OnKey "^v", "" Application.OnKey "+{INSERT}", "" End Sub Private Sub Workbook_WindowDeactivate(ByVal Wn As Window) 'Enable when switching away Application.OnKey "^C" Application.OnKey "^c" Application.OnKey "^{INSERT}" Application.OnKey "^V" Application.OnKey "^v" Application.OnKey "+{INSERT}" End Sub Regards Stephen Bullen Microsoft MVP - Excel www.BMSLtd.ie |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Disable # | Excel Discussion (Misc queries) | |||
Disable Alt+F11 | Excel Discussion (Misc queries) | |||
disable F1 | Excel Discussion (Misc queries) | |||
Disable the name box | Excel Programming | |||
Disable ALT KEY | Excel Programming |