Quick Start > Open a Session From a Microsoft Excel Macro |
You can open an InfoConnect session from another application that supports VBA.
![]() |
Visual Basic uses a standard set of protocols called Automation (or OLE Automation) that allows one application to communicate with other applications. Any application that supports Automation can communicate with any other application. This means that an InfoConnect session can communicate with other InfoConnect sessions, Microsoft Office products, stand-alone Visual Basic, or any other product that supports Automation. |
This example shows how to open an InfoConnect session document from an Excel macro.
Open a InfoConnect session from an Excel Macro
Open a session |
Copy Code
|
---|---|
Private Sub OpenReflectionIBMSession() 'Declare an object variable for the InfoConnect application Dim app As Attachmate_Reflection_Objects_Framework.ApplicationObject 'Declare frame, terminal, and view object variables: Dim frame As Attachmate_Reflection_Objects.frame Dim terminal As Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmTerminal Dim view As Attachmate_Reflection_Objects.view 'If an instance of InfoConnect is open, get a handle to it On Error Resume Next Set app = GetObject("InfoConnect Workspace") 'Otherwise, create a new instance of InfoConnect On Error GoTo 0 If IsEmpty(app) Or (app Is Nothing) Then Set app = New Attachmate_Reflection_Objects_Framework.ApplicationObject End If With app 'wait until InfoConnect initalizes Do While .IsInitialized = False .Wait 200 Loop 'Get a handle to the Frame object Set frame = .GetObject("Frame") 'Make the frame visible so we can view the workspace frame.Visible = True End With 'Create an Ibm3270 control using an .rd3x session document file Set terminal = app.CreateControl(Environ$("USERPROFILE") & _ "\Documents\Micro Focus\InfoConnect\" & "mySavedSession.rd3x") 'Create a view so that we can display the session Set view = frame.CreateView(terminal) End Sub |
Open a session |
Copy Code
|
---|---|
Private Sub OpenReflectionOpenSystemsSession() 'Declare an object variable for the InfoConnect application Dim app As Attachmate_Reflection_Objects_Framework.ApplicationObject 'Declare frame, terminal, and view object variables: Dim frame As Attachmate_Reflection_Objects.frame Dim terminal As Attachmate_Reflection_Objects_Emulation_OpenSystems.terminal Dim view As Attachmate_Reflection_Objects.view 'If an instance of InfoConnect is already open, get a handle to it On Error Resume Next Set app = GetObject("InfoConnect Workspace") 'Otherwise, create a new instance of InfoConnect On Error GoTo 0 If IsEmpty(app) Or (app Is Nothing) Then Set app = New Attachmate_Reflection_Objects_Framework.ApplicationObject End If With app 'wait until InfoConnect is initialized Do While .IsInitialized = False .Wait 200 Loop 'Get a handle to the Frame object. Set frame = .GetObject("Frame") 'Make the frame visible so we can view the workspace frame.Visible = True End With 'Create an Open Systems terminal control using an .rdox sesssion document file Set terminal = app.CreateControl(Environ$("USERPROFILE") & _ "\Documents\Micro Focus\InfoConnect\" & "mySavedSession.rdox") 'Create a view so that we can display the session Set view = frame.CreateView(terminal) End Sub |
To open a session from another application, you'll need to use the InfoConnect ApplicationObject, IbmTerminal or Terminal, Frame, and View objects:
For more about these objects, see Using the InfoConnect Object Model.