Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Disable Shortcuts

Is ther a way to disable all keyborad shortcuts in a "For Each" or similiar


--
Roger
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Disable Shortcuts

Do you mean shortcuts assigned to macros or all shortcuts, like ctrl-c copy,
or both..

Regards,
Peter T


"Roger" wrote in message
...
Is ther a way to disable all keyborad shortcuts in a "For Each" or

similiar


--
Roger



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Disable Shortcuts

Peter - just the excel ones like ctrl-c copy


--
Roger


"Peter T" wrote:

Do you mean shortcuts assigned to macros or all shortcuts, like ctrl-c copy,
or both..

Regards,
Peter T


"Roger" wrote in message
...
Is ther a way to disable all keyborad shortcuts in a "For Each" or

similiar


--
Roger




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Disable Shortcuts

Sub test()

SetShortcuts True ' disable shortcuts

' SetShortcuts False ' reset shortcuts

End Sub

Sub DummyMacro()
' no code in the macro
MsgBox "DummyMacro" ' just to test
End Sub

Sub SetShortcuts(bDisable As Boolean)
Dim i As Long, j As Long
Dim sMacro As String, sKey As String
Dim vArr

vArr = Array("^", "+^") ' (ctrl, shift-ctrl)
sMacro = "'" & ThisWorkbook.Name & "'!DummyMacro"

For i = Asc("a") To Asc("z") ' 97 to 122
For j = 0 To 1
sKey = vArr(j) & Chr(i)

If bDisable Then
Application.OnKey sKey, sMacro
Else
Application.OnKey sKey
End If
Next
Next

End Sub

Assigs ctrl & ctrl+shift a to z to the dummy macro. Adapt if you also want
to include
numbers and the F keys. See OnKey in help

Regards,
Peter T

"Roger" wrote in message
...
Peter - just the excel ones like ctrl-c copy


--
Roger


"Peter T" wrote:

Do you mean shortcuts assigned to macros or all shortcuts, like ctrl-c

copy,
or both..

Regards,
Peter T


"Roger" wrote in message
...
Is ther a way to disable all keyborad shortcuts in a "For Each" or

similiar


--
Roger






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Disable Shortcuts

Actually it seems the Dummy macro is not required at all. Try this -

Sub SetShortcuts(bDisable As Boolean)
Dim i As Long, j As Long
Dim sKey As String
Dim vArr

vArr = Array("^", "+^") ' (ctrl, shift-ctrl)

For i = Asc("a") To Asc("z") ' 97 to 122
For j = 0 To 1
sKey = vArr(j) & Chr(i)

If bDisable Then
Application.OnKey sKey, ""
Else
Application.OnKey sKey
End If
Next
Next

End Sub

Regards,
Peter T


"Peter T" <peter_t@discussions wrote in message
...
Sub test()

SetShortcuts True ' disable shortcuts

' SetShortcuts False ' reset shortcuts

End Sub

Sub DummyMacro()
' no code in the macro
MsgBox "DummyMacro" ' just to test
End Sub

Sub SetShortcuts(bDisable As Boolean)
Dim i As Long, j As Long
Dim sMacro As String, sKey As String
Dim vArr

vArr = Array("^", "+^") ' (ctrl, shift-ctrl)
sMacro = "'" & ThisWorkbook.Name & "'!DummyMacro"

For i = Asc("a") To Asc("z") ' 97 to 122
For j = 0 To 1
sKey = vArr(j) & Chr(i)

If bDisable Then
Application.OnKey sKey, sMacro
Else
Application.OnKey sKey
End If
Next
Next

End Sub

Assigs ctrl & ctrl+shift a to z to the dummy macro. Adapt if you also want
to include
numbers and the F keys. See OnKey in help

Regards,
Peter T

"Roger" wrote in message
...
Peter - just the excel ones like ctrl-c copy


--
Roger


"Peter T" wrote:

Do you mean shortcuts assigned to macros or all shortcuts, like ctrl-c

copy,
or both..

Regards,
Peter T


"Roger" wrote in message
...
Is ther a way to disable all keyborad shortcuts in a "For Each" or
similiar


--
Roger









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Disable Shortcuts

Thanks Peter - very useful
--
Roger


"Peter T" wrote:

Actually it seems the Dummy macro is not required at all. Try this -

Sub SetShortcuts(bDisable As Boolean)
Dim i As Long, j As Long
Dim sKey As String
Dim vArr

vArr = Array("^", "+^") ' (ctrl, shift-ctrl)

For i = Asc("a") To Asc("z") ' 97 to 122
For j = 0 To 1
sKey = vArr(j) & Chr(i)

If bDisable Then
Application.OnKey sKey, ""
Else
Application.OnKey sKey
End If
Next
Next

End Sub

Regards,
Peter T


"Peter T" <peter_t@discussions wrote in message
...
Sub test()

SetShortcuts True ' disable shortcuts

' SetShortcuts False ' reset shortcuts

End Sub

Sub DummyMacro()
' no code in the macro
MsgBox "DummyMacro" ' just to test
End Sub

Sub SetShortcuts(bDisable As Boolean)
Dim i As Long, j As Long
Dim sMacro As String, sKey As String
Dim vArr

vArr = Array("^", "+^") ' (ctrl, shift-ctrl)
sMacro = "'" & ThisWorkbook.Name & "'!DummyMacro"

For i = Asc("a") To Asc("z") ' 97 to 122
For j = 0 To 1
sKey = vArr(j) & Chr(i)

If bDisable Then
Application.OnKey sKey, sMacro
Else
Application.OnKey sKey
End If
Next
Next

End Sub

Assigs ctrl & ctrl+shift a to z to the dummy macro. Adapt if you also want
to include
numbers and the F keys. See OnKey in help

Regards,
Peter T

"Roger" wrote in message
...
Peter - just the excel ones like ctrl-c copy


--
Roger


"Peter T" wrote:

Do you mean shortcuts assigned to macros or all shortcuts, like ctrl-c

copy,
or both..

Regards,
Peter T


"Roger" wrote in message
...
Is ther a way to disable all keyborad shortcuts in a "For Each" or
similiar


--
Roger








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 keyboard shortcuts Pegasus Excel Discussion (Misc queries) 21 July 1st 07 12:23 PM
Disable the built-in keyboard shortcuts Ben Daia Excel Programming 1 May 15th 07 07:52 PM
disable shortcuts Josh C Excel Programming 6 May 2nd 07 05:06 PM
Disable keyboard shortcuts in formula edit mode? Dirk Van de moortel Excel Programming 1 December 16th 05 03:07 PM
How to disable the shortcuts of excel files created by MSExcel 20. Nikhil Excel Discussion (Misc queries) 1 February 19th 05 12:40 PM


All times are GMT +1. The time now is 05:29 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"