NWildblood
Technical User
Hi, I have a piece of code I'd love to re-write without all the Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Can anyone assist ?
I'm generating some jobs in Extra screen from and Excel, getting the new job numbers once they are generated, then pasting them back in the excel spreadsheet for the client.
I'd really like to slick things up by using
Do While Sess.Screen.OAI.Xstatus <> 0
Or similar, but my EB knowledge is still at monkey-see monkey do... can anyone show me the way??
Sub CreateJobWithIF()
'Test To create jobs with an IF statement
'--------------------------------------------------------------------------------
' Get the main system object
Dim i_cols As Integer, msg_line As String
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System Is Nothing) Then
MsgBox "Could not create the EXTRA System object. Stopping macro playback."
Stop
End If
Set Sessions = System.Sessions
If (Sessions Is Nothing) Then
MsgBox "Could not create the Sessions collection object. Stopping macro playback."
Stop
End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
g_HostSettleTime = 50 ' milliseconds
OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If
' Get the necessary Session Object
Dim CSS As Object
Set CSS = GetObject("C:\Documents and Settings\zeicri\Desktop\SMNXS06.edp")
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 Is Nothing) Then
MsgBox "Could not create the Session object. Stopping macro playback."
Stop
End If
If Not Sess0.Visible Then Sess0.Visible = True
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
i_cols = Sess0.Screen.Cols
msg_line = Trim(Sess0.Screen.GetString(24, 1, i_cols))
xlrow = 3
Sess0.Screen.SendKeys ("<Home>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("ASMJ")
Sess0.Screen.SendKeys ("<Enter>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
'Sess0.Screen.SendKeys ("<Tab>")
Do While Trim(Range("A" & xlrow).Value) <> ""
Sess0.Screen.SendKeys ("HQjob<NewLine><Tab>IPT")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys (Trim(Range("E" & xlrow).Value))
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("<NewLine>mx")
Sess0.Screen.SendKeys (Trim(Range("g" & xlrow).Value))
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("<Tab>")
Sess0.Screen.SendKeys (Trim(Range("H" & xlrow).Value))
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("<NewLine><NewLine>A<Tab><NewLine><Delete><EraseEOF>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys (Trim(Range("J" & xlrow).Value))
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("<NewLine>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys (Trim(Range("K" & xlrow).Value))
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("<NewLine><NewLine>")
Sess0.Screen.SendKeys (Trim(Range("L" & xlrow).Value))
Sess0.Screen.SendKeys (Trim(Range("M" & xlrow).Value))
Sess0.Screen.SendKeys (Trim(Range("N" & xlrow).Value))
Sess0.Screen.SendKeys ("exxxHQ<NewLine><NewLine>803206425<Enter>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
If InStr(1, UCase(msg_line), UCase("TW007 - Required by Date less than End Date")) > 0 Then
Sess0.Screen.PutString "y", 24, 62 ' location of "y"
Sess0.Screen.SendKeys ("<Enter>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
End If
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("<Enter>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("y")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("<Enter><Enter>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Range("R" & xlrow).Value = Trim(Sess0.Screen.GetString(22, 30, 6))
xlrow = xlrow + 1
Sess0.Screen.SendKeys ("<Pf9>")
Loop
MsgBox "DONE", vbOKOnly, "End of Batch"
System.TimeoutValue = OldSystemTimeout
End Sub
----
Thanks !
Can anyone assist ?
I'm generating some jobs in Extra screen from and Excel, getting the new job numbers once they are generated, then pasting them back in the excel spreadsheet for the client.
I'd really like to slick things up by using
Do While Sess.Screen.OAI.Xstatus <> 0
Or similar, but my EB knowledge is still at monkey-see monkey do... can anyone show me the way??
Sub CreateJobWithIF()
'Test To create jobs with an IF statement
'--------------------------------------------------------------------------------
' Get the main system object
Dim i_cols As Integer, msg_line As String
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System Is Nothing) Then
MsgBox "Could not create the EXTRA System object. Stopping macro playback."
Stop
End If
Set Sessions = System.Sessions
If (Sessions Is Nothing) Then
MsgBox "Could not create the Sessions collection object. Stopping macro playback."
Stop
End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
g_HostSettleTime = 50 ' milliseconds
OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If
' Get the necessary Session Object
Dim CSS As Object
Set CSS = GetObject("C:\Documents and Settings\zeicri\Desktop\SMNXS06.edp")
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 Is Nothing) Then
MsgBox "Could not create the Session object. Stopping macro playback."
Stop
End If
If Not Sess0.Visible Then Sess0.Visible = True
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
i_cols = Sess0.Screen.Cols
msg_line = Trim(Sess0.Screen.GetString(24, 1, i_cols))
xlrow = 3
Sess0.Screen.SendKeys ("<Home>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("ASMJ")
Sess0.Screen.SendKeys ("<Enter>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
'Sess0.Screen.SendKeys ("<Tab>")
Do While Trim(Range("A" & xlrow).Value) <> ""
Sess0.Screen.SendKeys ("HQjob<NewLine><Tab>IPT")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys (Trim(Range("E" & xlrow).Value))
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("<NewLine>mx")
Sess0.Screen.SendKeys (Trim(Range("g" & xlrow).Value))
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("<Tab>")
Sess0.Screen.SendKeys (Trim(Range("H" & xlrow).Value))
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("<NewLine><NewLine>A<Tab><NewLine><Delete><EraseEOF>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys (Trim(Range("J" & xlrow).Value))
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("<NewLine>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys (Trim(Range("K" & xlrow).Value))
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("<NewLine><NewLine>")
Sess0.Screen.SendKeys (Trim(Range("L" & xlrow).Value))
Sess0.Screen.SendKeys (Trim(Range("M" & xlrow).Value))
Sess0.Screen.SendKeys (Trim(Range("N" & xlrow).Value))
Sess0.Screen.SendKeys ("exxxHQ<NewLine><NewLine>803206425<Enter>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
If InStr(1, UCase(msg_line), UCase("TW007 - Required by Date less than End Date")) > 0 Then
Sess0.Screen.PutString "y", 24, 62 ' location of "y"
Sess0.Screen.SendKeys ("<Enter>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
End If
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("<Enter>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("y")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("<Enter><Enter>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
Range("R" & xlrow).Value = Trim(Sess0.Screen.GetString(22, 30, 6))
xlrow = xlrow + 1
Sess0.Screen.SendKeys ("<Pf9>")
Loop
MsgBox "DONE", vbOKOnly, "End of Batch"
System.TimeoutValue = OldSystemTimeout
End Sub
----
Thanks !