Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Excel to Extract Data out of Attachmate Reflection Workspace

Status
Not open for further replies.

brianandstewie

Programmer
Sep 12, 2013
1
US
I am trying to do something, ideally, simple, but I am not familiar with writing in Excel to work with Reflection Workspace. From what I notice from all the search online is that Reflections is in an emulator, so I might not be thinking of things correctly.

But my goal is to use Excel to simply select an area in Reflection (i.e. row 2, column 2 to row 2, column 5), copy the data and paste it in a cell within Excel. That's it. No reports, nothing special. I know it's simple, but I am teaching myself and I'm starting with the basics. Can someone help me?
 
hi,
Code:
hi,

First set a reference to the Attachmate Reflections m.n Object Library in VB Editor Tools > References

I use Attachmate Extra, so my code references the Extra Terminal Emulator.

I also use a LOGIN procedure that assigns the public variables, because I have lots of different SCREEN names that I can call that will use those objects.

[code]
Option Explicit

Public oSystem As ExtraSystem
Public oSessions As ExtraSessions
Public oSess As ExtraSession
Public oScrn As ExtraScreen

Sub IMS_Login(Optional bContinue As Boolean = False)

    Dim result, datarefreshed, bLogin As Boolean
    
    Set oSystem = CreateObject("Extra.System")
    '"C:\Program Files\E!PC\65Backup\Sessions\MVSB1 Session1.EDP"
    If oSystem.Sessions.Count = 0 Then
        Set oSess = oSystem.Sessions.Open("C:\Program Files\E!PC\Sessions\mvsb1.edp")
'        ufmPassword.Show
        ufmPassword.Show
        bLogin = True
    Else
        Set oSess = oSystem.ActiveSession
        bLogin = False
    End If
    
    With oSess
        .Visible = True
        .WindowState = xNORMAL
    End With

    Set oScrn = oSess.Screen
    If (oScrn Is Nothing) Then GoTo ExitMacro
    
    With oScrn
        If bLogin Then
        ' BHT SignOn
            Do Until .WaitForCursor(17, 28)
                DoEvents
            Loop
            .Area(17, 28, 17, 28) = "S"
            .SendKeys ("<ENTER>")
        ' Login
            Do Until .WaitForCursor(14, 37)
                DoEvents
            Loop
            .Area(14, 37, 14, 46) = fOSUserName()
            .Area(15, 37, 15, 46) = vPassword
            .SendKeys ("<ENTER>")
        ' SuperSession
            Do Until .WaitForCursor(9, 2)
                DoEvents
            Loop
            .Area(11, 2, 11, 2) = "S"
            .SendKeys ("<ENTER>")
        ' IMS Ready
        End If
    End With

'...Macro Magic happens here...

ExitMacro:
    If bContinue Then Exit Sub
    Set oScrn = Nothing
    Set oSess = Nothing
    Set oSystem = Nothing
End Sub

BTW, after a SendKeys command that trigers an asynchronous process, I use a feedback technique to look for the cursor to appear at the screen's rest position.

If you're already logged in, as it appears you are, just assign the objects for the system, session and screen. and you're ready for the next step.

To grab data from row 2, column 2 to row 2, column 5 and put it in sheet1 A1, for instance you could do this...
Code:
  Sheets(1).Cells(1,1).value = oScrn.Area(2,2,2,5).value

Since I'm asked to get data from the IMS system given a list of key values, I've devised a way to 1) define any screen's fields in a screen definition table, 2) Grab ALL the data from the screen for the given key value, parse it based on the screen definition table and write the results to an Excel sheet/table for that screen (I have several dozen screens thus defined). Then the specific data that a user might be intrested in is just a subset of that table. Sometimes I have to scrape/collect data from one screen in order to get the data from one or more others to accomplish the necessary task. Sure is a LOT easier with this canned approch.

Just thot I'd throw that in for no extra charge ;-)


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top