HostExplorer/Hummingbird through Visual Basic coding help

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
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")


'-------------------------------------------
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.







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:

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi Friend,

i knew that you have found the solution at the end.

Can you please share the details how to jump cursor to a position we decide in hummingbird/host explorer.

Myhost.textrc(9(Row),12(Column)). How could i use this to jump to a specific position instead

Myhost.runcmd ("Tab")
Myhost.runcmd ("Tab")
Myhost.runcmd ("Tab")
Myhost.runcmd ("Enter")

Please help!!!!!!!!!!!!!
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,202
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top