Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable # bmelt Excel Discussion (Misc queries) 8 February 18th 09 04:39 PM
Disable Alt+F11 Bob Excel Discussion (Misc queries) 3 April 27th 06 10:05 PM
disable F1 12505-5B Excel Discussion (Misc queries) 1 February 16th 05 08:03 PM
Disable the name box markedwardfriedman Excel Programming 1 November 13th 03 09:46 AM
Disable ALT KEY Dunce in SC[_2_] Excel Programming 2 October 26th 03 11:41 PM


All times are GMT +1. The time now is 09:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"