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!

Handling Multiple Open Sessions 1

Status
Not open for further replies.

Inovate

Technical User
Oct 24, 2006
15
US
I am attempting to find a way to write a macro in Excel that refers to Attatchmate sessions, the problem is that the only code that I can get to work is
Set Sess=sys.ActiveSession
However I want to creat a list box that the user can pick which open Attachmate session they want to use to run the macro. I have viewed several posts and I can not get the macro to run right. Any help would be appreciative.
 
I read this thread and did not have any luck the macro errors out at
ExtraSession = frmSelectSession.lstSelectSession.ListIndex + 1

and I am unable to determine why? any suggestions?
 
The code in the thread is referring specifically to VB. This line of code actually manipulates an already opened form. You'll need to convert that to an Extra Basic dialog box and add the data there. This is not an operation that is as easy as it would seem.

You may want to first use Msgbox in the code to see how the code works and identifies the sessions. If you aren't already familiar with Arrays and Dialog boxes then this will be a very confusing task.

calculus
 
Show us the code your working with. Do you have a Form with a listbox at this point, or do you need help creating the form?

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
What I have is a large macro that currently works using activesession command but the problem is that when different users use this they end up having to close all but one session of attachmate because the macro seems to use different sessions that is unpredictable. So what I was attempting to do is determine which Sessions are active and have the user click on the session they want to use. I have done similiar tasks in Microsoft Access using forms and VBA Code. But I have no idea how to create a list form using VBA userforms I am attempting to read up on it now, but any help you could provide in this would be wonderful and help me out considerably.
 
Go into the VBA editor and select Insert->UserForm. You can then draw the listbox onto the form.
 
I have done that and then I am assuming according to the code that Calculus suggested that the name of the userform would be changed to frmselectsessions and that the listbox would be named lstselectsessions.....That is where I am currently at.....and working from there....any additional pointer or tips?
 
this is how i define 6 different sessions. don't know if this is what you are looking for.

Code:
Sub OpenAll()

Dim System As Object
Dim Sessions As Object
Dim QPads As Object
Dim QPad  As Object
Dim Session1  As Object
Dim Session2  As Object
Dim Session3  As Object
Dim Session4  As Object
Dim Session5  As Object
Dim Session6  As Object
Set System = CreateObject("EXTRA.System")
Set Sessions = System.Sessions
Sessions.CloseAll
Set Sess1 = Sessions.Open("C:\BLACK.EDP")
Set Sess2 = Sessions.Open("C:\MAUVE.EDP")
Set Sess3 = Sessions.Open("C:\WHITE.EDP")
Set Sess4 = Sessions.Open("C:\GRAPE.EDP")
Set Sess5 = Sessions.Open("C:\GREEN.EDP")
Set Sess6 = Sessions.Open("C:\BROWN.EDP")
Sess1.Visible = 1
Sess2.Visible = 1
Sess3.Visible = 1
Sess4.Visible = 1
Sess5.Visible = 1
Sess6.Visible = 1
 
I considered this senario however every computer that runs the macro seems to have the *.edp file stored somewhere else, like the desktop, mydocuments, quicklinks,etc. So although that would be the easiest way it will not work for everyone. Thank you for the suggestion.
 
The way I handled this was to store all the sessions that the macro require under one common file directory. When the macro is fired, only these sessions would be used. When my macro is invoked, it would close all other sessions that has nothing to do with the macro.I have duplicate sessions on the Desktop as well as shortcuts to the sessions that the macro requires.
 
Inovate,
As ususal I'm a little late to the party. Here is a sample for Excel that you can use. As with any code it could use some error handlers and validation steps, but if you are still working on the problem you might find it helpfull.

Module1
Code:
Sub TestListbox()
Dim strItem As String
Load UserForm1
Do
  'Add some items to the listbox, replace this with your Session.Name code
  strItem = InputBox("Prompt")
  UserForm1.ListBox1.AddItem strItem
Loop Until strItem = ""
'This will pause the code execution while the form is visible
UserForm1.Show vbModal
'Grab the selected item and close the for
strItem = UserForm1.ListBox1.Value
Unload UserForm1

'This is where you would connect to the session you want
Debug.Print strItem
End Sub

UserForm1[tt]
List box : ListBox1
Command Button : CommandButton1
Form Code:[/tt]
Code:
Private Sub CommandButton1_Click()
'DON'T UNLOAD THE FORM, we need the value from the listbox first
'so hide the form and let the calling routine close the form
Me.Hide
End Sub

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top