ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disabling Commands (https://www.excelbanter.com/excel-programming/288136-disabling-commands.html)

Loomah

Disabling Commands
 
Hi
I'm trying to disable a few commands (like Copy etc).

I'm using the following to address all command bar controls as necessary

Sub Find_Disable_Commands()
Dim myControls As CommandBarControls
Dim ctl As CommandBarControl
Set myControls = CommandBars.FindControls _
(Type:=msoControlButton, ID:=21) 'cut
For Each ctl In myControls
ctl.Enabled = 0
Next ctl
End Sub

The next part is disabling keyboard shortcuts. I'm aware of one way to do
this which is to create a 'blank' macro and assign the keyboard shortcut to
it, eg assign Ctrl+X to
Sub Kut()
'nothing here!
End Sub

The question is, is this the best way to do this (I 've done it manually)
and if so how do I reset the normal shortcut command when leaving the
workbook ie make Ctrl+X into cut again when closing the book or switching
between books??

Many thanks in advance




Tom Ogilvy

Disabling Commands
 
Look in help at the OnKey method. This is the way to disable and reset
shortcuts.

--
Regards,
Tom Ogilvy

"Loomah" wrote in message
...
Hi
I'm trying to disable a few commands (like Copy etc).

I'm using the following to address all command bar controls as necessary

Sub Find_Disable_Commands()
Dim myControls As CommandBarControls
Dim ctl As CommandBarControl
Set myControls = CommandBars.FindControls _
(Type:=msoControlButton, ID:=21) 'cut
For Each ctl In myControls
ctl.Enabled = 0
Next ctl
End Sub

The next part is disabling keyboard shortcuts. I'm aware of one way to do
this which is to create a 'blank' macro and assign the keyboard shortcut

to
it, eg assign Ctrl+X to
Sub Kut()
'nothing here!
End Sub

The question is, is this the best way to do this (I 've done it manually)
and if so how do I reset the normal shortcut command when leaving the
workbook ie make Ctrl+X into cut again when closing the book or switching
between books??

Many thanks in advance







All times are GMT +1. The time now is 01:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com