Skip to main content

Hello,
First off, I'm so glad that I've found this community. I am hoping that someone can give me a hand doing identifying existing reflection sessions.

I'm able to open a new instance of reflections and then automate that using this code.


Public Sub SeperateReflections()
Dim MyObject As Reflection.Session 'Reflection for IBM
Set MyObject = CreateObject("ReflectionIBM.Session")


MyObject.Visible = True
MyObject.OpenSettings rcSettings, "C:\\Users\\New.rsf"
MyObject.TransmitANSI ("Works")
MyObject.RunExternalMacro "C:\\Users\\New.rsf", "TimeLoopWait", ""

End Sub


But what I'm trying to do is loop through all open versions of reflections, and then enter some information in each one.


I've seen some solutions using the attachmates EXTRA! program, but I can't get any of those to work with the tools in the reflections reference library.


I would really appreciate any kind of tips or tricks.


#Reflection
#Reflection14.x

Hello,
First off, I'm so glad that I've found this community. I am hoping that someone can give me a hand doing identifying existing reflection sessions.

I'm able to open a new instance of reflections and then automate that using this code.


Public Sub SeperateReflections()
Dim MyObject As Reflection.Session 'Reflection for IBM
Set MyObject = CreateObject("ReflectionIBM.Session")


MyObject.Visible = True
MyObject.OpenSettings rcSettings, "C:\\Users\\New.rsf"
MyObject.TransmitANSI ("Works")
MyObject.RunExternalMacro "C:\\Users\\New.rsf", "TimeLoopWait", ""

End Sub


But what I'm trying to do is loop through all open versions of reflections, and then enter some information in each one.


I've seen some solutions using the attachmates EXTRA! program, but I can't get any of those to work with the tools in the reflections reference library.


I would really appreciate any kind of tips or tricks.


#Reflection
#Reflection14.x
Reflection 14.x and earlier does not have a "sessions" collection like EXTRA does, so it is not as easy to check something in all sessions that might be open. If you use your app to open sessions, save the session object variable that you create when opening the session for later use, that way you can check it again later if you need to.

Otherwise, it is possible to enumerate open sessions by using the GetObject function. The Reflection session object has a property called OLEServerName, and for IBM sessions, this always has a default value of "RIBM". So, if a session is open, you can get a pointer to it by using GetObject like this:

Set sessObj = GetObject("RIBM") 'VBA

Once you retrieve a session object in this way, you can set the value of its OLEServerName property to something else, and you can keep calling GetObject("RIBM") again until an error occurs...this way you can eventually do something with all open sessions.

Dim sessObj As Object
On Error Resume Next
Do While True
Set sessObj = GetObject("RIBM")
If Err = 0 Then
sessObj.Caption = "Found this one!"
sessObj.OLEServerName = "xRIBM"
Else
MsgBox "No more sessions."
Err.Clear
Exit Do
End If
Loop
On Error GoTo 0


Hope that helped. The current version, Reflection Desktop 16.0, has better methods for getting access to open sessions.