How to export data from several host screens to cells in an Excel spreadsheet

How to export data from several host screens to cells in an Excel spreadsheet

A macro can be used to "scrape" specific table data from the current Flex Terminal Emulator host screen, export to cells within a newly created Excel spreadsheet, then repeat this process to traverse multiple host screens.  The sample macro code below demonstrates this:

Sample Code:


Sub Main()

' Create the Excel objects
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = true
Set objWorkbook = objExcel.Workbooks.Add

nRow = 1
nCol = 1

  For i = 1 to 4
    objExcel.Cells(nRow, nCol).Value = FlexScreen.GetText (FlexScreen.Position(4, 2), 6)
    objExcel.Cells(nRow, nCol+1).Value = FlexScreen.GetText (FlexScreen.Position(4, 10), 20)
    objExcel.Cells(nRow, nCol+2).Value = FlexScreen.GetText (FlexScreen.Position(4, 31), 8)
    objExcel.Cells(nRow+1, nCol).Value = FlexScreen.GetText (FlexScreen.Position(5, 2), 6)
    objExcel.Cells(nRow+1, nCol+1).Value = FlexScreen.GetText (FlexScreen.Position(5, 10), 20)
    objExcel.Cells(nRow+1, nCol+2).Value = FlexScreen.GetText (FlexScreen.Position(5, 31), 8)
    objExcel.Cells(nRow+2, nCol).Value = FlexScreen.GetText (FlexScreen.Position(6, 2), 6)
    objExcel.Cells(nRow+2, nCol+1).Value = FlexScreen.GetText (FlexScreen.Position(6, 10), 20)
    objExcel.Cells(nRow+2, nCol+2).Value = FlexScreen.GetText (FlexScreen.Position(6, 31), 8)
    objExcel.Cells(nRow+3, nCol).Value = FlexScreen.GetText (FlexScreen.Position(7, 2), 6)
    objExcel.Cells(nRow+3, nCol+1).Value = FlexScreen.GetText (FlexScreen.Position(7, 10), 20)
    objExcel.Cells(nRow+3, nCol+2).Value = FlexScreen.GetText (FlexScreen.Position(7, 31), 8)
    Ok = FlexScreen.SendKeys(FlexKey.PF1)
    Ok = FlexScreen.WaitForNoX()
    nRow = nRow+4
  Next
End Sub

Notes:

  • The above sample code assumes 4 rows and 3 columns of data per host screen at specific locations, then advances to the next screen using the PF1 host key. 
  • The statement "For i = 1 to 4" determines how many screens of data to export.  Adjust the number 4 to your desired number of screens to export.
  • You may copy the above sample code, paste into Notepad or another text editor, then save to the Macros subfolder of the FlexTerm user directory with the .ams file extension to utilize in your environment.

    • Related Articles

    • How to export a host screen to Microsoft Word

      A macro can be used to "scrape" the data from the current Flex Terminal Emulator host screen and export to a Word document. The sample macro code below demonstrates this: Sample Code: Sub Main() ' Create the Word objects Set objWord = ...
    • How to export a host screen to a new Outlook email message

      A macro can be used to "scrape" the data from the current Flex Terminal Emulator host screen and export to a newly created Outlook email message. The sample macro code below demonstrates this: Sample Code: Sub Main() Dim outobj, mailobj ' Determine ...
    • How to override translations for particular host characters

      There are certain characters that do not translate correctly on my host. Is there some way to override translations to get the desired result? As of Flex Terminal Emulator version 4.0.4024.1512, overriding of character translations is now possible. ...
    • What host code pages are available in Flex Terminal Emulator

      The following host code pages are supported in Flex Terminal Emulator: 037 US / Canada 273 Austria / Germany 277 Denmark / Norway 278 Finland / Sweden 280 Italy 284 Spain / Latin America 285 United Kingdom 297 France 500 International 1140 US / ...
    • How to maximize the Flex Terminal Emulator host screen area

      Users may wish to hide or disable some of the advanced features of Flex Terminal Emulator in order to acquire additional space for the host screen area. Below are some tips to help accomplish this: Status Bar By default, the Status Bar is displayed ...