Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 210
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default 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

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
Why doesn't ths VBA Code work? Mac Lingo[_2_] Excel Programming 1 November 24th 05 02:03 AM
How can I get this code to work? Sam Excel Programming 1 February 2nd 05 12:24 AM
Why my code do not work : - ( keepitcool Excel Programming 5 September 5th 03 06:28 PM
Why my code do not work : - ( Tom Ogilvy Excel Programming 1 August 31st 03 04:53 PM
Why my code do not work : - ( Bob Phillips[_5_] Excel Programming 0 August 31st 03 01:27 PM


All times are GMT +1. The time now is 04:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"