Dynamically Open a Session
In This Topic
You can open or close sessions dynamically. This example shows how to open a terminal session from another session that is running in the InfoConnect workspace.
If you prefer to run macros in pre-configured sessions instead of creating your own sessions, you can download the VBA Sample Sessions and open the dynamically-open-session.rd3x (IBM) and dynamically-open-session.rdox (Open Systems) files. The download package contains everything you need to run the macros in these files. See Download the VBA Sample Sessions.
Create the Session Document you Want to Open
- Open InfoConnect and create the session you want to open.
- Save the session in a trusted location. For this example, we saved a session named "gettingStarted" in the Documents/Micro Focus/InfoConnect folder.
You can open only sessions that are saved in trusted locations (Documents/Micro Focus/InfoConnect is a default trusted location). For information about trusted locations and how to add them, see the InfoConnect Help.
Create a Macro to open the Session
- Create or open a new InfoConnect session.
- On the Tools tab, select Visual Basic to open the Visual Basic Editor.
- In the Visual Basic Project Explorer, right click on the project folder, and choose Insert > Module.
- If the session you want to open is not the same terminal type as your existing session, add a reference to the session terminal type. For example, if you are running an Open Systems terminal session and you want to open an IBM terminal session document, you'll need to add a reference to the Attachmate_Reflection_Objects_Emulation_IbmHosts library. To do this, select your project folder in the Project window. Then select Tools > References on the Visual Basic Editor and select the library.
- Copy the following code into the module and press F5 to run it.
Concepts
To open a session, you'll need access to the Application, IbmTerminal (IBM) or Terminal (Open Systems), and View objects:
- The ApplicationObject is the InfoConnect application.
- The Frame object is the top-level user interface component for the workspace and it can be used to control the display of the workspace and to create views for the terminal controls running in the workspace.
- The IbmTerminal (or Terminal) object is the top level control for the new session. The CreateControl method returns the appropriate terminal control for the session document file that you pass to it.
- The View object represents the user interface aspect of the new session. To display the session, we need to create a View Object for the terminal and we do this using the Frame object.
For more about these objects, see Using the InfoConnect Object Model.
You can also create this macro in a Common project module and then call it to open this session. Macros in the Common project can be called by any session or by workspace actions. For more about this, see Sharing and Referencing Macros and Controlling Macro Execution.
See Also