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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you Pause 3 seconds? 1

Status
Not open for further replies.

link99sbc

Technical User
Apr 8, 2009
141
US
I'm trying to pause my excel macro in attachmate.
Excel has no pause feature like attachmate. I've
tried to use Sessions settletime but excel just slows
down. I've tried to pause in attachmate sendkeys but
Excel doesn't compile it. I need to pause at a screen
for 3 seconds.
I'm using sendkeys that don't funcion in each particular
screen I need to view for 3 seconds before the macro moves
on. This works, just looking for a better way.
Code:
Sub clear()
    
    ActiveCell.Offset(0, -2) = 1
    ActiveCell.Offset(1, 0).Activate
    Selection.Copy
    
    Dim Sessions As Object
    Dim System As Object
    Set System = CreateObject("EXTRA.System")
    Dim Sess0 As Object
    Set Sess0 = System.ActiveSession
    Set Field = System.ActiveSession.Screen.Area(4, 18, 4, 26)
    Field.Select
    Field.Delete
    Field.Value = ActiveCell
    
    SendKeys "%{TAB}"
    
    Do While Sess0.Screen.OIA.Xstatus <> 0
    DoEvents
    Loop
    
    SendKeys "{ENTER}"
    Sess0.Screen.SendKeys ("<Enter>")
    Do While Sess0.Screen.OIA.Xstatus <> 0
    DoEvents
    Loop
    Call Check
End Sub

Sub bill()

    ActiveCell.Offset(0, -1) = 1
    ActiveCell.Offset(1, 0).Activate
    Selection.Copy
    
    Dim Sessions As Object
    Dim System As Object
    Set System = CreateObject("EXTRA.System")
    Dim Sess0 As Object
    Set Sess0 = System.ActiveSession
    Set Field = System.ActiveSession.Screen.Area(4, 18, 4, 26)
    Field.Select
    Field.Delete
    Field.Value = ActiveCell
    
    SendKeys "%{TAB}"
    
    Do While Sess0.Screen.OIA.Xstatus <> 0
    DoEvents
    Loop
    
    SendKeys "+{ENTER}"
    Sess0.Screen.SendKeys ("<Enter>")
    Do While Sess0.Screen.OIA.Xstatus <> 0
    DoEvents
    Loop
    Call Check
    
End Sub

Sub Check()
               
        Dim Sessions As Object
        Dim System As Object
        Set System = CreateObject("EXTRA.System")
        Dim Sess0 As Object
        Set Sess0 = System.ActiveSession
        SendKeys "{F11}"                 'opens the screen I need to view
        Do While Sess0.Screen.OIA.Xstatus <> 0
        DoEvents
        Loop
        SendKeys "{F11}"                 'F11 doesn't work in this screen
        SendKeys "{F11}"                 'therefore giving me about 2 to
        SendKeys "{F11}"                 '3 seconds to view. I need to pause 3
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
        SendKeys "{F11}"
                       
        SendKeys "{F3}"
        Do While Sess0.Screen.OIA.Xstatus <> 0
        DoEvents
        Loop
        Call Check2
End Sub

Sub Check2()

        Dim Sessions As Object
        Dim System As Object
        Set System = CreateObject("EXTRA.System")
        Dim Sess0 As Object
        Set Sess0 = System.ActiveSession

        Sess0.Screen.Moveto 8, 4
        Sess0.Screen.SendKeys ("1207")
        Sess0.Screen.Moveto 8, 53
        Sess0.Screen.SendKeys ("rev<ENTER>")                 
        Do While Sess0.Screen.OIA.Xstatus <> 0
        DoEvents
        Loop
        Sess0.Screen.Moveto 10, 2
        Sess0.Screen.SendKeys ("r<ENTER>")        'Opens the screen I need to view.

        SendKeys "{F9}"                           'F9 doesn't work in this screen
        SendKeys "{F9}"                           'therefore giving me about 2 to
        SendKeys "{F9}"                           '3 seconds to view. I need to pause 3
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
        SendKeys "{F9}"
                        
        SendKeys "{F3}"
        Do While Sess0.Screen.OIA.Xstatus <> 0
        DoEvents
        Loop
        Call Reset
        
End Sub
        
Sub Reset()

        Dim Sessions As Object
        Dim System As Object
        Set System = CreateObject("EXTRA.System")
        Dim Sess0 As Object
        Set Sess0 = System.ActiveSession
 
        Sess0.Screen.Moveto 8, 4
        Do While Sess0.Screen.OIA.Xstatus <> 0
        DoEvents
        Loop
        
        Sess0.Screen.SendKeys ("<EraseEOF>")
        
        Sess0.Screen.Moveto 8, 53
        Do While Sess0.Screen.OIA.Xstatus <> 0
        DoEvents
        Loop
        
        Sess0.Screen.SendKeys ("<EraseEOF>")
        Do While Sess0.Screen.OIA.Xstatus <> 0
        DoEvents
        Loop
        
        Sess0.Screen.SendKeys ("<Enter>")
        Do While Sess0.Screen.OIA.Xstatus <> 0
        DoEvents
        Loop
        
        Sess0.Screen.Moveto 4, 22
End Sub
 
Yes it didn't work. It makes Excel pause before it runs the macro.
 
Found It
Replaced all the Sendkeys with this
Code:
        newHour = Hour(Now())
        newMinute = Minute(Now())
        newSecond = Second(Now()) + 3
        waitTime = TimeSerial(newHour, newMinute, newSecond)
        Application.Wait waitTime
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top