Disable Keyboard shortcuts

L

Loomah

Hi
I'm trying to disable keyboard shortcuts such as CTRL+X. I've been looking
for something similar to the OnKey method available in Excel but all I have
been able to piece together is the code below. Everything I've seen in the
help files etc suggests I'm right here but the fact that it doesn't work
suggests I'm not that smart!!! I have been able to assign new combinations
to a test macro and then remove that combination while I've been
experimenting.

I have no real experience of Word VBA but a fair bit in XL.

The follow up problem would be where to place this code (if it worked) or
the correct version of it so that a change in document would not be affected
(same as Workbook Activate & Deactivate events)

Sub DisableCut()
CustomizationContext = NormalTemplate
FindKey(BuildKeyCode(wdKeyControl, wdKeyX)).Clear
End Sub

Sub EnableCut()
CustomizationContext = NormalTemplate
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyX), _
KeyCategory:=wdKeyCategoryCommand, Command:="editcut"
End Sub


Thanks in advance
Any help is greatly appreciated
;-)
 
W

Word Heretic

G'day "Loomah" <[email protected]>,

check out the KeyBindings collection.


Steve Hudson
Word Heretic Sydney Australia
Tricky stuff with Word or words

Email: WordHeretic at tpg.com.au


Loomah was spinning this yarn:
 
L

Loomah

Steve
Thanks for the reply but you'll see that I've kind of got that far (although
I have no real idea what I've done) from the code I have posted. Problem is
it won't work for CTRL+X. I haven't tried it with other standard shortcuts
such as CTRL+C or V or S or A etc. I did have success with something lifted
from the help files to assign a macro and an operation to a key combo and
then removing it but no success with the editcut operation.

Also another key issue is controlling the code for when a document is active
or not.

any further suggestions??

Cheers
Loomah
;-)
 
W

Word Heretic

G'day "Loomah" <[email protected]>,

issue 1

Instead of .clear, try .disable.

issue 2

if activedocument.template="The right one" then
'do the stuff only for when certain dox are loaded
end if



Steve Hudson
Word Heretic Sydney Australia
Tricky stuff with Word or words

Email: WordHeretic at tpg.com.au


Loomah was spinning this yarn:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top