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

work with 2 sessions 3

Status
Not open for further replies.

sal0003

Programmer
Apr 5, 2010
22
IT
I need to work with 2 session from the same macro code in vba for excel... is possibble?
Tks.
 



hi,
Code:
Public Sessions As Object
Public System As Object
Public Sess0 As Object
Public Sess1 As Object
dim Sess as object

'Extra Objects
    Set System = CreateObject("EXTRA.System")   ' Gets the system object
    If (System Is Nothing) Then MsgBox "Could not create the EXTRA System object.  Stopping macro playback.": Stop
    Set Sessions = System.Sessions
    If (Sessions Is Nothing) Then: MsgBox "Could not create the Sessions collection object.  Stopping macro playback.": Stop
    Set Sess0 = System.ActiveSession
    If (Sess0 Is Nothing) Then MsgBox "Could not create the Session object.  Stopping macro playback.": Stop
    
    for each sess in sessions
       if sess.name <> Sess0.name then
          set Sess1 = sess
       end if
    next

...Macro Magic happens here...


Set Sessions = Nothing
Set System = Nothing
Set Sess0 = Nothing
Set Sess1 = Nothing


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Sorry, I am not very clear on this as I am new to programming. Let say I am running two sessions XXX-AB1 and XXX-AB2. How do I direct excel vba to go the session I want. My macro always goes to the last active session. please help.
 


Code:
    sSessName = "XXX-AB1"
    for each sess in sessions
       if sess.name <> sSessName then
          set Sess1 = sess
          exit for
       end if
    next
'now manipulate the screen in this session

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Hi any macro's where I'm using 2 Attachmate screen I use the below code and work great gives both screens a name i.e first session is sess0. and 2nd is sess.1 and so if commanding screen one its sess0.screen. and if commanding screen 2 its sess1.screen. Hope this is of some use.

Dim Sess0 As Object
SessName0$ = "Standalone_WMIS.EDP"

Set Sess0 = Sessions.Item(SessName0$)
If Sess0 Is Nothing Then
Err = MsgBox(SessName0 + " is not currently open. Open it?", 1)
If 1 = Err Then
Err = 0
Set Sess0 = Sessions.Open(SessName0)
If Err Then
MsgBox ("Failed to open " + SessName0 + ". Stopping playback")
Stop
End If
ElseIf 2 = Err Then
Stop
Else
MsgBox ("Failed to open " + SessName0 + ". Stopping playback")
Stop
End If
End If
If Not Sess0.Visible Then Sess0.Visible = True
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)

Dim Sess1 As Object
SessName1$ = "\\NA-11\burrowr6\My Documents\Programs\NBBS-USER.EDP"

Set Sess1 = Sessions.Item(SessName1$)
If Sess1 Is Nothing Then
Err = MsgBox(SessName1 + " is not currently open. Open it?", 1)
If 1 = Err Then
Err = 0
Set Sess1 = Sessions.Open(SessName1)
If Err Then
MsgBox ("Failed to open " + SessName1 + ". Stopping playback")
Stop
End If
ElseIf 2 = Err Then
Stop
Else
MsgBox ("Failed to open " + SessName1 + ". Stopping playback")
Stop
End If
End If
If Not Sess1.Visible Then Sess1.Visible = True
Sess1.Screen.WaitHostQuiet (g_HostSettleTime)
 
why doesnt Set Sess0 = System.Active Session do the same as these solutions above ?
 

wozza261,

Please start a new thread with your question. Please include ALL the related code.

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