Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel in Edit mode 1

Status
Not open for further replies.

freezorburn

Programmer
Mar 19, 2004
6
US
The user is editing a cell but never presses enter. The cursor blinks in the cell and no macros can run.

I tried a loop that dose a sendkeys "esc" every 5 min and that works but the Loop kills the cpu usage.

How can I get excel to get out of edit mode every 5 min or so? Please help.
 
you can't - if the user is sitting there with the cursor in the formula bar, there is nothing you can do except educate the user

Rgds, Geoff

Never test the depth of water with both feet

Help us to help you by reading FAQ222-2244 before you ask a question
 
Thank you all and this web site,

I got it! The answer for me was to start a loop and do a sendKey "ECS" every x seconds. The loop dose not take any processer time if you delay the loop with the Sleep command. You must Declare The sleep function api.


Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function GetActiveWindow Lib "user32" () As Long

'
'*************************************************************************************
'Routine : CursorBump
'Created On : 01/02/04
'Created By : Ken Alvarez
'About : Bumps Cursor out of edit mode
'Ver 01/02 Initial Version Did not Use this procedure but
' did use the onkey nto disable F2
' 04/13 Need to use cusorbump but takes too much Processer
' time (waah,waah) so Added a delay
'**************************************************************************************
Public Sub CursorBump()
Dim PauseTime, Start, Finish, TotalTime
On Error GoTo CursorBumpError

Do
PauseTime = TIMER_CursorBump ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
Sleep 1 ' Tried using wait command but
DoEvents ' Yield to other processes.
Loop

'We check for row 37 again becuase the user could move cells during the time loop.
'We check for excel being active window
'We check for toptapositions being the Active Application
If GetActiveWindow <> 0 And Not ActiveCell.Row = CursorBump_Row And ActiveWindow.Caption = "TopTAPositions.xls" Then
'Debug.Print GetActiveWindow
Application.SendKeys "{ESC}"
End If
Loop
'Application.OnTime Now + TimeValue(PauseTime), "CursorBump"
Exit Sub

CursorBumpError:

MsgBox Err.Description
End Sub
 
very nice - have a star for posting the solution back

Rgds, Geoff

Never test the depth of water with both feet

Help us to help you by reading FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top