Answers for "Reflections Excel Data Code"

0

Reflections Excel Data Code

Sub PutDataIntoScreen()
    'Declare an object variable for the Reflection object:
    Dim app As Attachmate_Reflection_Objects_Framework.ApplicationObject
    
    'Declare additional Reflection objects, such as frame, terminal, and view:
    Dim frame As Attachmate_Reflection_Objects.frame
    Dim terminal As Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmTerminal
    Dim view As Attachmate_Reflection_Objects.view
    Dim screen As Attachmate_Reflection_Objects_Emulation_IbmHosts.ibmScreen
    
    'Declare a variables for the cell data, return code, and counter
    Dim cellData As String, project As String, group As String, projectType As String, member As String
    Dim rCode As ReturnCode
    Dim row As Integer
  
    'Assign the Application object to the object variable. The following code creates an instance of Reflection:
    Set app = New Attachmate_Reflection_Objects_Framework.ApplicationObject
  
    'wait until Reflection initializes
    Do While app.IsInitialized = False
        app.Wait 200
    Loop
  
    'Create controls to open and display the session document.
    Set frame = app.GetObject("Frame")
    Set terminal = app.CreateControl2("09E5A1B4-0BA6-4546-A27D-FE4762B7ACE1")
                           
    terminal.HostAddress = "demo:ibm3270.sim"
    Set view = frame.CreateView(terminal)
    frame.Visible = True
    'navigate to the screen you want to enter data into
    Set screen = terminal.screen
    rCode = screen.SendControlKey(ControlKeyCode_Transmit)
    rCode = screen.WaitForHostSettle(3000, 2000)
  
    rCode = screen.SendKeys("ISPF")
    rCode = screen.SendControlKey(ControlKeyCode_Transmit)
    rCode = screen.WaitForHostSettle(3000, 2000)
  
    rCode = screen.SendKeys("2")
    rCode = screen.SendControlKey(ControlKeyCode_Transmit)
    rCode = screen.WaitForHostSettle(3000, 2000)
  
    'Get text and copy it in row by row, starting at row 6
    row = 6
  
    'Loop through rows until an empty cell is encountered
    Do
       'Get the data from Excel
       project = Cells(row, 2).Value
       group = Cells(row, 3).Value
       projectType = Cells(row, 4).Value
       member = Cells(row, 5).Value
 
       'Put the data into the appropriate fields
       rCode = screen.PutText2(project, 5, 18)
       rCode = screen.PutText2(group, 6, 18)
       rCode = screen.PutText2(projectType, 7, 18)
       rCode = screen.PutText2(member, 8, 18)

       'Transmit the data to the host and wait for the screen to be ready for more input
       rCode = screen.PutText2("autoexec", 2, 15)
       rCode = screen.SendControlKey(ControlKeyCode_Transmit)
       rCode = screen.WaitForHostSettle(3000, 2000)
       rCode = screen.SendControlKey(ControlKeyCode_F3)
       rCode = screen.WaitForHostSettle(3000, 2000)
 
       'Increment the counter to the next row
       row = row + 1
    
       'Find out if the next row contains data
       cellData = Cells(row, 2).Value
    
   Loop While cellData <> ""
 
End Sub
Posted by: Guest on January-29-2022

Browse Popular Code Answers by Language