johnywhy
New Member
- Joined
- Sep 12, 2008
- Messages
- 47
- Office Version
- 365
- 2019
- 2016
- 2013
- 2011
- 2010
- 2007
- Platform
- Windows
- MacOS
Halo
I want to run a macro with OnKey, but then I want the normal key behavior to execute.
Neither of these two approaches work; both produce an endless loop. I'd like a solution which will work with ANY single or combination keystroke.
Sub keyEvent()
Debug.Print "a typed"
With Application
.OnKey "a"
.SendKeys "a"
.OnKey "a", "keyEvent"
End With
End Sub
Public Sub keyEvent()
Debug.Print "a typed"
With Application
.EnableEvents = False
.SendKeys "a"
.EnableEvents = True
End With
End Sub
I want to run a macro with OnKey, but then I want the normal key behavior to execute.
Neither of these two approaches work; both produce an endless loop. I'd like a solution which will work with ANY single or combination keystroke.
Sub keyEvent()
Debug.Print "a typed"
With Application
.OnKey "a"
.SendKeys "a"
.OnKey "a", "keyEvent"
End With
End Sub
Public Sub keyEvent()
Debug.Print "a typed"
With Application
.EnableEvents = False
.SendKeys "a"
.EnableEvents = True
End With
End Sub