×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

calling a user defined session in attachmate macro

calling a user defined session in attachmate macro

calling a user defined session in attachmate macro

(OP)
I am having some problems allowing the user to specify which session they would like to use when running a macro.
 
Users on our system can open two Attachmate windows, one named WGS.edp and the other named WGSSession.edp.  These
names are constant in our system, regardless of the desktop the application is being run on.
When you first sign on to a session on our system, you can enter either TPXC or TPXW.  If you have a session open, and are logged in to it using TPXC, you MUST log in to the other session using TPXW.  What I would like to do is set it so a value of TPXC (gotten from input via tpxTextBox.text and assigned to the variable TPX) always uses the "WGS" session and a value of TPXW to always use the "WGSSession" session.

i format my object the standard way via Sess0 = System.ActiveSession

i tried using some 'if' logic to assign a session based on the value of TPX

CODE

If TPX = "TPXC" then
    Sess0 = System.ActiveSession.WGS
Else
    Sess0 = System.ActiveSession.WGSSession
end if
 but im thinking now it might just be

CODE

Sess0 = System.Session.WGS
or

CODE

sess0 = System.Session.WGSSession

any help would be greatly appreciated

thanks
-obfuscate

 

RE: calling a user defined session in attachmate macro



Did you follow up on what you were thinking?

Hint:  Only ONE session can be 'active'.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: calling a user defined session in attachmate macro

(OP)
im in a really weird development situation (perfectly legal and sanctioned though) so when i have access to the system, i dont have acces to visual studio and when i have access to visual studio, i dont have access to the system. the situation is crazy stupid but thanks for sending me down the right path

ill let you know how it works out

all to often in programming i find myself looking so deeply at complexly at a problem to find the answer, i miss the simple solution that might be (probably is) floating right in front of my face.

 

RE: calling a user defined session in attachmate macro

(OP)
ok, ive decided to give targeting a specific Session using my screen ripper thats written in VBA, code is as follows below
Say i want to target the WGS Session....
the code below results in a 438 Run Time Error with msg 'object doesnt support this property or method'

CODE

Sub ScreenRip()
    Dim System, Sess0, Sessions, excel_app As Object
    ' Get the main system object
        Set System = CreateObject("EXTRA.System")   
            If (System Is Nothing) Then
                MsgBox "Could not create the EXTRA System object.  Stopping macro playback."
                Stop
            End If
        Set Sessions = System.Sessions

        If (Sessions Is Nothing) Then
            MsgBox "Could not create the Sessions collection object.  Stopping macro playback."
            Stop
        End If
    
        'Set the time for the host screen to settle
        g_HostSettleTime = 250
        g_HostSettleTime1 = 1000


        If (g_HostSettleTime > System.TimeoutValue) Then
            System.TimeoutValue = g_HostSettleTime
        End If

        Set Sess0 = System.Session.WGS
        
        If (Sess0 Is Nothing) Then
            MsgBox "Could not create the Session object.  Stopping macro playback."
            Stop
        End If
        If Not Sess0.Visible Then Sess0.Visible = True
        Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
        
        Dim Row, Column, rCount, cCount As Integer
        Dim ExcelSource, toExcel As String
        Dim test As Integer
        
        
        ExcelSource = "c:\excel\ScreenRun.xls"
        
        Set excel_app = CreateObject("Excel.Application")
        excel_app.Workbooks.Open (ExcelSource)
        Set excel_sheet = ActiveSheet
        
        rCount = 1
        Row = 1
        Column = 1
        
        Do While rCount <= 24
            cCount = 1
    
            Do While cCount <= 80
                toExcel = ""
                toExcel = Sess0.Screen.Area(rCount, cCount, rCount, cCount).Value
                excel_sheet.Cells(rCount, cCount).Value = toExcel
                cCount = cCount + 1
            Loop
                
            rCount = rCount + 1
        
        Loop
               
        MsgBox ("Screen rip complete.  Please change the target file 'ScreenRun' to get the capture to a new tab and formatted properly")
               
End Sub

If i can just figure out how to target specific session by name I will be able to figure out how to use a variable to target the session I need but what i have just isint doing it

To clarify, I do have access to VBA and the system at the same time, i just have to take it home to code it in VS2008

RE: calling a user defined session in attachmate macro

(OP)

CODE

 Set Sess0 = System.Sessions(WGS)

muh hahahahaha

thanks for letting me bounce ideas around, im new here so ill do my best to make sure im on and contributing

<>bfuscate

RE: calling a user defined session in attachmate macro




You never seem to declare WGS or assign or set WGS.

So what is it?

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: calling a user defined session in attachmate macro

see if this helps you

CODE

    Sub Main()
    Dim Sys As Object, Sess As Object
    Set Sys = CreateObject("EXTRA.System")
' Assumes one or more open sessions
    SessionCount = Sys.Sessions.Count
    For i = 1 to SessionCount
      If Sys.Sessions.Item(i).Connected Then
        Connected$ = Connected$ + Sys.Sessions.Item(i).Name + " "
      End If
    Next
    MsgBox "The following sessions are connected: " + Connected$
End Sub

RE: calling a user defined session in attachmate macro

(OP)
WGS/WGSSession is just the actual name of the session window (WGS.edp)

yea, i dont think my idea of System.Session(WGS) is working altough for some reason a VBA version will execute in the WGS window while i have my VB version running in the WGSSession window (the vb macro uses the statement Sess0 = System.ActiveSession) but always seems to go to WGSSession.

When i leave the VBA code for the second session as

CODE

sess0 = System.ActiveSession
the macro will error because they are both trying to use the same session
but when i use

CODE

Sess0 = System.Sessions(WGS)
it will run in the WGS window while the VB macro runs in the WGSSession window

i cant make two different versions of the VBA sub use different windows though


grrrrr






 

RE: calling a user defined session in attachmate macro



Quote:

WGS/WGSSession is just the actual name of the session window (WGS.edp)

Then you use as...

CODE

Set Sess0 = System.Sessions("WGS/WGSSession")
or something similar in QUOTES.
 

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: calling a user defined session in attachmate macro

(OP)
interestingly enough, the quotes are not needed, i figured out the problem, i was running the actual WGS.edp file itself while when running the WGSSession, i was using a shortcut to launch the file.  apparently this screwed up the way it is named/referenced somehow and affected its ability to recognize the correct session, even though it was named the same

Sess0 = System.Sessions(WGS)

and

Sess0 = System.Session(WGSSession)

are valid and working fine via VBA (wierd, i know)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close