vzdog
Technical User
- Apr 8, 2008
- 33
I am using a macro to send a command to an Attachmate session. I have an Excel worksheet that is called by the Macro in Attachmate.
It puts the data from column B in to the Attachmate session and sends it.as you can see it loops until an empty cell.
No Problem, works Great.....but
the host session provides a response that I need to capture back on to the Excel spreadsheet.
Can anyone give me an idea of how to do this?
It puts the data from column B in to the Attachmate session and sends it.as you can see it loops until an empty cell.
No Problem, works Great.....but
the host session provides a response that I need to capture back on to the Excel spreadsheet.
Can anyone give me an idea of how to do this?
Code:
' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$
Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
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 = 3000 ' milliseconds
OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If
' Get the necessary Session Object
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)
'--------------------------------------------------------------------------------
'Declare the Excel Object
Dim xlApp As Object, xlSheet As Object, MyRange As Object
Set xlApp = CreateObject("excel.application")
xlApp.Application.DisplayAlerts = False 'Turn off Warning Messages'
xlApp.Visible = True
xlApp.Workbooks.Open FileName:="D:\PMDaily\Fetch.xls"
Set xlSheet = xlApp.activesheet
Set MyRange = xlApp.activesheet.Range("B:B")
Dim Row As Long
With xlApp.ActiveSheet
Set MyRange = .Range("B2:B65536").Resize(xlApp.CountA(.Range("B2:B65536")))
End With
For Row = 1 To MyRange.Rows.Count
Sess0.Screen.PutString MyRange.Rows(Row).Value, 24, 6
Sess0.Screen.SendKeys "<ENTER>"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Next Row
End Sub