Here is an example of code that I use to extract information from Attachmate. I hope this helps.
' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$
Sub ExtractFreight
' Get the main system object
Dim Sessions As Object
Dim I as Integer
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 = 100 ' 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 variables to contain the OLE objects
Dim objExcel As Object
Dim objWorkBook As Object
Dim gs as String
Dim r as Integer
Dim j as Integer
r=1
On Error Resume Next
' Attempt to get a reference to an open instance of Excel
Set objExcel = GetObject(, "Excel.Application")
If objExcel Is Nothing Then
'If GetObject failed, open a new instance of Excel
Set objExcel = CreateObject("Excel.Application")
If objExcel Is Nothing Then
MsgBox ("Could not open Excel.")
Exit Sub
End If
End If
' Make Excel visible on the screen
objExcel.Visible = True
' Create a new Workbook
Set objWorkBook = objExcel.Workbooks.Open("C:\macro\get freight fob\get freight fob.xls")
' BEFORE YOU RUN THIS YOU HAVE TO BE IN THE "MM" SCREEN WITH "VQ" IN THE FUNCTION FIELD
' Copy the result from Excel to host row 16 column 1-3
Do
result = objWorkBook.WorkSheets("Sheet1").Cells(r,1).Value 'Gets vendor number
Sess0.Screen.PutString result, 05, 25 'Enters vendor number
Sess0.Screen.Sendkeys("<Enter>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
gs = Sess0.Screen.GetString (14, 12, 15) 'Gets Freight desc
objWorkBook.WorkSheets("Sheet1").Cells(r,2).Value = gs 'Transfers freight desc to Excel
gs = Sess0.Screen.GetString (15, 47, 15) 'Gets FOB desc
objWorkBook.WorkSheets("Sheet1").Cells(r,3).Value = gs 'Transfers FOB desc to Excel
Sess0.Screen.Sendkeys("<Pf1>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
r=r+1
Loop Until objWorkBook.WorkSheets("Sheet1").Cells(r,1).Value = ""
' Excel will remain open after this Sub ends.
' To close out Excel, unremark the following 4 lines of code. .
'objWorkBook.Close
'objExcel.Quit
'set objWorkBook = Nothing
'set objExcel = Nothing
End sub