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

calling a user defined session in attachmate macro

Status
Not open for further replies.

obfuscate

Programmer
Feb 8, 2010
29
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

 


Did you follow up on what you were thinking?

Hint: Only ONE session can be 'active'.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
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.

 
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
 
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
 



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

So what is it?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
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
 
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






 


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,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
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)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top