I copied this code which was posted by WinblowsME and modified it to serve my purpose. The only thing that I need is when running the macro instead of overwriting the text file I want to create a new file with the name of a string located in a specific location of the Extra screen or a unique value like a sequential number. Either way will work. Any thoughts?
Basically I want to scrape the current Extra screen, create a new text file and name the text file with a unique name from either a value in the Extra screen or a sequential number. This is the code so far
Basically I want to scrape the current Extra screen, create a new text file and name the text file with a unique name from either a value in the Extra screen or a sequential number. This is the code so far
Code:
Declare Sub Wait()
GLOBAL Sys as Object
GLOBAL Sess as Object
Sub Main()
Dim outfile As String, aline As String
Dim i as Integer, iRows As Long, iCols As Long
outfile = "C:\Documents and Settings\burnside_carlos\My Documents\Attachmate\EXTRA!\Scrape.txt"
Set Sys = CreateObject("Extra.System")
If Sys Is Nothing Then
MsgBox ("Could not create Extra.System...is E!PC installed on this machine?")
Exit Sub
End If
Set Sess = Sys.ActiveSession
If Sess Is Nothing Then
MsgBox ("No session available...stopping macro playback.")
Exit Sub
End If
' ###
If UCase(Sess.Screen.GetString(1, 2, 4)) = "RGAM" Then
iRows = Sess.Screen.Rows
iCols = Sess.Screen.Cols
Open outfile For Output As #1
Do
For i = 1 To iRows
aline = UCase(Trim(Sess.Screen.GetString(i, 1, iCols)))
Print #1, aline
Next i
Wait
' If line 24 contains "RET AUTH MAINT" stop the loop.
Loop While Trim(Sess.Screen.GetString(2, 1, iCols)) = "RETURN AUTHORIZATION MAINTENANCE"
Close #1
Else
MsgBox "You must be in the RGAM screen to run macro." ' Displays a message box if not in RGAM
End If
End Sub
Sub Wait()
Do While Sess.Screen.OIA.Xstatus <> 0
DoEvents
Loop
End Sub