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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open previously saved sessions with Visual Basic

Status
Not open for further replies.

Shaves

Technical User
Feb 11, 2008
17
0
0
US
I have previously saved sessions for each cost center in "R:\Cost Centers\Sessions\. If I don't use these sessions at least once every ninety days, they are automatically disabled. I would like to set up a little VBA macro to open each session and logon in. Once the session is open, I will be able to navigate around the screen and login as I already have macros that do the login piece. I'm struggling with opening each session. Any help would be greatly appreciated. Thank you for taking the time to look at this...........We are using Reflections 2014
 
Hi,

When you say Session, are you referring to a Screen (transaction) accessing the same mainframe db?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Skip...........When I refer to session, I'm referring to a specific "rd5x" file that was previously saved. Our company uses different machines / mainframes for different cost centers. The macros I write generally start with a "rd5x" file already open. However, in this case, I want to open a specific "rd5x" file. Once it is open, I can automate the login process, close the file and then move on to the next one. Thanks for the help. Let me know if you have any more questions.....Shaves
 
My experience is with AttachmateExtra.

In Extra, the System can be opened with a saved file as you have indicated, that connects the emulator to the specific mainframe. Sessions are objects within a System.

In Extra you can Set a System object via a file to open that mainframe connection. Then establish the ActiveSession as the Session to which a Screen can be assigned.

Don't know what the Reflections syntax is to accomplish that.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Can you show me some code to open a session in Extra....maybe I can compare the code to Reflections and see if I can find something similar? Thanks
 
Here's some code I used before I retired. I always ran from Excel VBA because I was screen scraping for my users. Turns out I was wrong about System. It IS the Session object that assigns the mainframe...
Code:
Option Explicit
'you must have a reference set for Attachmate EXTRA! n.m Object Library
'runs with Form ufmPassword

Public oSystem As ExtraSystem
Public oSessions As ExtraSessions
Public oSess As ExtraSession
Public oScrn As ExtraScreen
Public vPassword
Public sCurrentScreenName As String

Sub IMS_Login(Optional bContinue As Boolean = False)

    Dim result, bLogin As Boolean
    
    Set oSystem = CreateObject("Extra.System")
    
    If oSystem.Sessions.Count = 0 Then
        [b][highlight #FCE94F]Set oSess = oSystem.Sessions.Open("C:\Program Files\E!PC\Sessions\Mainframe.edp[/highlight]")[/b]
'        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
    
    oSystem.TimeoutValue = 100
    
    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


Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Sorry for the delayed response. That is exactly what I am doing. Running a macro and screen scraping data for end users. I'm going to work with this next week to see if I can get it to work for me. The only difference is that I haven't used EXTRA. Thanks for all of the help with this........
 
My experience has been that I started in Extra VB but very quickly realized that since mr data was to end up in Excel to send to my users and since I often has a source list to begin with in Excel as well and since the VB editor was klunky compared to the Excel VB editor, I did ALL my coding in Excel.

I you do as well, add a Reference in Excel VB via Tools > References to the Reflections object library.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top