![]() |
Why does this code not work?
Attempting to make the regular enter key behave as if you press Alt-Enter, in
responce to someones post about how to do this. Pressing the standard enter key (not the numeric keypad enter) causes an infinite loop. The screen flickers with an hour-glass after pressing enter. Ctrl-Break stops the code and it is always on the Sub AltEnterRtn() line. Can anyone explain what is going on behind the scenes that causes this? Sub SetKey() Application.OnKey "~", "AltEnterRtn" End Sub Sub ResetKey() Application.OnKey "~" End Sub Sub AltEnterRtn() Application.SendKeys "%~", True End Sub -- Regards, John |
Why does this code not work?
It's getting caught in an infinite loop because after recognizing the enter
key, it is processing another enter routine, creating the loop. -- http://HelpExcel.com 1-888-INGENIO 1-888-464-3646 x0197758 "John Keith" wrote: Attempting to make the regular enter key behave as if you press Alt-Enter, in responce to someones post about how to do this. Pressing the standard enter key (not the numeric keypad enter) causes an infinite loop. The screen flickers with an hour-glass after pressing enter. Ctrl-Break stops the code and it is always on the Sub AltEnterRtn() line. Can anyone explain what is going on behind the scenes that causes this? Sub SetKey() Application.OnKey "~", "AltEnterRtn" End Sub Sub ResetKey() Application.OnKey "~" End Sub Sub AltEnterRtn() Application.SendKeys "%~", True End Sub -- Regards, John |
Why does this code not work?
It does seem that way, but
Wouldn't I have to have had Sub SetKey() Application.OnKey "~", "AltEnterRtn" Application.OnKey "%~", "AltEnterRtn" End Sub For the Sendkeys forcing an Alt-Enter to then cause the loop? The Sendkeys (alt-Enter) should not be causing the OnKey for the standalone Enter to fire. Or its that I don't understand what OnKey is doing in this case. (Probably so since everyday I find out how much more there is that I dont know.) Can you think of a way to get around this loop, so that pressing Enter will cause an in-cell line break instead of having to use Alt-Enter? -- Regards, John "galimi" wrote: It's getting caught in an infinite loop because after recognizing the enter key, it is processing another enter routine, creating the loop. -- http://HelpExcel.com 1-888-INGENIO 1-888-464-3646 x0197758 "John Keith" wrote: Attempting to make the regular enter key behave as if you press Alt-Enter, in responce to someones post about how to do this. Pressing the standard enter key (not the numeric keypad enter) causes an infinite loop. The screen flickers with an hour-glass after pressing enter. Ctrl-Break stops the code and it is always on the Sub AltEnterRtn() line. Can anyone explain what is going on behind the scenes that causes this? Sub SetKey() Application.OnKey "~", "AltEnterRtn" End Sub Sub ResetKey() Application.OnKey "~" End Sub Sub AltEnterRtn() Application.SendKeys "%~", True End Sub -- Regards, John |
All times are GMT +1. The time now is 03:35 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com