timmytonga
New Member
- Joined
- Sep 23, 2011
- Messages
- 21
Hi,
I am trying to select content in my mainframe to set it as a variable. currently I am selecting and copying it and pasting to excel. Id like to jump to that position on the screen using the column and row coordinates and set it as Date1 and then move to the next and set it as Date2 basically I want to do away with this code
And make the code as efficient as possible. This would allow me to apply it in different scenarios as well. All help is greatly appreciated I cant seem to find any "Hummingbird" example code to learn from.
I am trying to select content in my mainframe to set it as a variable. currently I am selecting and copying it and pasting to excel. Id like to jump to that position on the screen using the column and row coordinates and set it as Date1 and then move to the next and set it as Date2 basically I want to do away with this code
Code:
'-----------------------------------------
MyHost.Runcmd ("Home")
MyHost.Runcmd ("Tab")
MyHost.Runcmd ("Tab")
MyHost.Runcmd ("Tab")
MyHost.Runcmd ("Tab")
MyHost.Runcmd ("Select-Word-Right")
MyHost.Runcmd ("Edit-Copy")
'-------------------------------------------
Code:
Sub Mainframe_test_code_ad_DATE_Extract()
Application.ScreenUpdating = False
Dim Host As Object
Dim HE As Object
Set HE = CreateObject("HostExplorer")
Set Host = HE.CurrentHost
Dim iPSUpdateTimeout
Dim HostExplorer As Object
Dim MyHost As Object
On Error GoTo GenericErrorHandler
Set HostExplorer = CreateObject("HostExplorer") ' Initialize HostExplorer Object
Set MyHost = HostExplorer.HostFromProfile("TOPS MF") ' Set object for the desired session
iPSUpdateTimeout = 60 ' PS Update wait time set to 60 seconds
'-------------------------------------
'EXCEL
'-------------------------------------
Dim wb1 As Workbook
Set wb1 = Application.ActiveWorkbook
Dim Firstrow As Long
Dim lastRow As Long
Dim Lrow As Long
Dim item1 As String
Dim Date1 As String
Dim Date2 As String
With ActiveSheet
.Select
Firstrow = .UsedRange.Cells(1).Row + 1
lastRow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
For Lrow = lastRow To Firstrow Step -1
item1 = Range("D" & Lrow).Value
'-------------------------------------
'Mainframe
'-------------------------------------
MyHost.Runcmd ("Home")
MyHost.Keys item1
MyHost.Runcmd ("Tab")
MyHost.Keys ("4")
MyHost.Runcmd ("Enter")
Rc = MyHost.WaitPSUpdated(iPSUpdateTimeout, True)
If Rc <> 0 Then GoTo OnWaitPSUpdatedTimeout
MyHost.Runcmd ("Home")
MyHost.Runcmd ("Tab")
MyHost.Runcmd ("Tab")
MyHost.Runcmd ("Tab")
MyHost.Runcmd ("Tab")
MyHost.Runcmd ("Select-Word-Right")
MyHost.Runcmd ("Edit-Copy")
wb1.Activate
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range("N" & Lrow)
MyHost.Runcmd ("Tab")
MyHost.Runcmd ("Select-Word-Right")
MyHost.Runcmd ("Edit-Copy")
wb1.Activate
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range("O" & Lrow)
Next Lrow
End With
Application.ScreenUpdating = True
'-------------------- Runtime Error Handlers --------------------
GenericErrorHandler:
MsgBox "Error " & Err & " : """ & Error(Err) & """ has occurred on line " & Erl - 1 & "." & Chr(10) & "Unable to continue macro execution.", 16, "HostExplorer Basic Macro Error"
Exit Sub
NoSession:
MsgBox "Profile ""TOPS MF"" is not running." & Chr(10) & "Unable to execute macro.", 16, "HostExplorer Macro Error"
Exit Sub
OnWaitPSUpdatedTimeout:
MsgBox "Timeout occured waiting for host to update screen." & Chr(10) & "Unable to continue macro execution.", 16, "HostExplorer Basic Macro Error"
Exit Sub
OnKeyboardError:
MsgBox "Unable to type string on host screen." & Chr(10) & "Unable to continue macro execution.", 16, "HostExplorer Basic Macro Error"
Exit Sub
End Sub
Last edited by a moderator: