NWildblood
Technical User
Hi, I currently successfully run various jobs in Attachmate Extra from VB code sitting in Excel. I have given an example below. My question is, how can I run similar VB directly from MS Access table instead ? Any answers *very* gratefully received... thanks
-------
Sub CertifySDH() 'to run from the sdhmatches spreadsheet produced by the cert engine
Dim System As Object, Sessions As Object, Sess As Object, CSS As Object
Dim msg_line As String
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 CSS = GetObject("C:\Documents and Settings\zeicri\Desktop\SMNXS06.edp")
Set Sess = System.ActiveSession
If (Sess Is Nothing) Then
MsgBox "Could not create the Session object. Stopping macro playback."
Stop
End If
If Not Sess.Visible Then Sess.Visible = True
msg_line = Trim(Sess.Screen.GetString(24, 1, Sess.Screen.Cols))
xlrow = 2
Sess.Screen.SendKeys ("<Home>MJB1<Enter>")
Call Wait(Sess)
Sess.Screen.SendKeys ("<Tab>")
Do While Trim(Range("A" & xlrow).Value) <> ""
Sess.Screen.SendKeys (Trim(Range("A" & xlrow).Value)) 'JOB NUMBER
Sess.Screen.SendKeys ("<Enter>")
Call Wait(Sess)
Sess.Screen.SendKeys ("<NewLine>")
Sess.Screen.SendKeys (Trim(Range("Q" & xlrow).Value)) 'APC
Sess.Screen.SendKeys ("<NewLine><NewLine><Delete><Tab><Delete><EraseEOF>")
Sess.Screen.SendKeys (Trim(Range("W" & xlrow).Value)) '1141
Sess.Screen.SendKeys ("<Enter>")
Call Wait(Sess)
Sess.Screen.SendKeys ("<Enter>")
Call Wait(Sess)
Sess.Screen.SendKeys ("<Pf16>")
Call Wait(Sess)
Sess.Screen.SendKeys (Trim(Range("Q" & xlrow).Value)) 'APC
Sess.Screen.SendKeys ("<Tab><Tab><Tab><Tab>")
Sess.Screen.SendKeys (Trim(Range("W" & xlrow).Value)) '1141
Sess.Screen.SendKeys ("<Delete><EraseEOF>")
Sess.Screen.SendKeys ("<NewLine><NewLine><NewLine><NewLine><NewLine><NewLine><NewLine>Y<Enter>")
Call Wait(Sess)
Sess.Screen.SendKeys ("<Pf5>")
Call Wait(Sess)
Sess.Screen.SendKeys ("1")
Call Wait(Sess)
Sess.Screen.SendKeys ("<Pf5>")
Call Wait(Sess)
Sess.Screen.SendKeys ("<NewLine><NewLine><Delete><EraseEOF>")
Sess.Screen.SendKeys (Trim(Range("U" & xlrow).Value)) 'ASSET ID
Sess.Screen.SendKeys ("<NewLine><Delete><EraseEOF>")
Sess.Screen.SendKeys (Trim(Range("V" & xlrow).Value)) 'ASSET DESC
Sess.Screen.SendKeys ("<Enter>")
Sess.Screen.WaitForString "TI004 - Modification Successful"
Sess.Screen.SendKeys ("<Pf3><Pf3>")
Call Wait(Sess)
xlrow = xlrow + 1
Sess.Screen.SendKeys ("<Pf9><Tab>")
Call Wait(Sess)
Loop
MsgBox "DONE", vbOKOnly, "End of Batch"
End Sub
----
Private Sub Wait(Sess As Object)
Do While Sess.Screen.OIA.XStatus <> 0
DoEvents
Loop
End Sub
----
"No-one got everything done by Friday except Robinson Crusoe...
-------
Sub CertifySDH() 'to run from the sdhmatches spreadsheet produced by the cert engine
Dim System As Object, Sessions As Object, Sess As Object, CSS As Object
Dim msg_line As String
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 CSS = GetObject("C:\Documents and Settings\zeicri\Desktop\SMNXS06.edp")
Set Sess = System.ActiveSession
If (Sess Is Nothing) Then
MsgBox "Could not create the Session object. Stopping macro playback."
Stop
End If
If Not Sess.Visible Then Sess.Visible = True
msg_line = Trim(Sess.Screen.GetString(24, 1, Sess.Screen.Cols))
xlrow = 2
Sess.Screen.SendKeys ("<Home>MJB1<Enter>")
Call Wait(Sess)
Sess.Screen.SendKeys ("<Tab>")
Do While Trim(Range("A" & xlrow).Value) <> ""
Sess.Screen.SendKeys (Trim(Range("A" & xlrow).Value)) 'JOB NUMBER
Sess.Screen.SendKeys ("<Enter>")
Call Wait(Sess)
Sess.Screen.SendKeys ("<NewLine>")
Sess.Screen.SendKeys (Trim(Range("Q" & xlrow).Value)) 'APC
Sess.Screen.SendKeys ("<NewLine><NewLine><Delete><Tab><Delete><EraseEOF>")
Sess.Screen.SendKeys (Trim(Range("W" & xlrow).Value)) '1141
Sess.Screen.SendKeys ("<Enter>")
Call Wait(Sess)
Sess.Screen.SendKeys ("<Enter>")
Call Wait(Sess)
Sess.Screen.SendKeys ("<Pf16>")
Call Wait(Sess)
Sess.Screen.SendKeys (Trim(Range("Q" & xlrow).Value)) 'APC
Sess.Screen.SendKeys ("<Tab><Tab><Tab><Tab>")
Sess.Screen.SendKeys (Trim(Range("W" & xlrow).Value)) '1141
Sess.Screen.SendKeys ("<Delete><EraseEOF>")
Sess.Screen.SendKeys ("<NewLine><NewLine><NewLine><NewLine><NewLine><NewLine><NewLine>Y<Enter>")
Call Wait(Sess)
Sess.Screen.SendKeys ("<Pf5>")
Call Wait(Sess)
Sess.Screen.SendKeys ("1")
Call Wait(Sess)
Sess.Screen.SendKeys ("<Pf5>")
Call Wait(Sess)
Sess.Screen.SendKeys ("<NewLine><NewLine><Delete><EraseEOF>")
Sess.Screen.SendKeys (Trim(Range("U" & xlrow).Value)) 'ASSET ID
Sess.Screen.SendKeys ("<NewLine><Delete><EraseEOF>")
Sess.Screen.SendKeys (Trim(Range("V" & xlrow).Value)) 'ASSET DESC
Sess.Screen.SendKeys ("<Enter>")
Sess.Screen.WaitForString "TI004 - Modification Successful"
Sess.Screen.SendKeys ("<Pf3><Pf3>")
Call Wait(Sess)
xlrow = xlrow + 1
Sess.Screen.SendKeys ("<Pf9><Tab>")
Call Wait(Sess)
Loop
MsgBox "DONE", vbOKOnly, "End of Batch"
End Sub
----
Private Sub Wait(Sess As Object)
Do While Sess.Screen.OIA.XStatus <> 0
DoEvents
Loop
End Sub
----
"No-one got everything done by Friday except Robinson Crusoe...