Show Contents / Index / Search

Automate Reflection 2011

Using Reflection objects and their methods and properties, you can control Reflection 2011 from applications that use Automation (such as Microsoft Word and Excel), or custom applications that you write in standalone Visual Basic.

By automating Reflection 2011, you can perform emulation tasks (such as extracting data or sending instructions) without ever leaving the application. For a list of Reflection objects, methods, and properties, see the Reflection language reference in the Microsoft Visual Basic Help.

Note: This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Attachmate provides this sample code "AS IS" with no warranties.

To automate Reflection 2011

  1. Declare an object variable for the Reflection object:

    Dim app As Attachmate_Reflection_Objects_Framework.ApplicationObject

  2. Assign the Application object to the object variable. The following code gets an existing instance of the application, if Reflection is running, or creates a new one, if it isn't running:

    Set app = GetObject("Reflection Workspace")

  3. Declare additional Reflection objects, such as Frame, Terminal, and View:

    Dim frame As Attachmate_Reflection_Objects.frame

    Dim terminal As Attachmate_Reflection_Objects_Emulation_IbmHosts.IbmTerminal

    Dim view As Attachmate_Reflection_Objects.view

  4. Create controls to open and display an existing session document. For the file path, include the drive letter and filename of the session document. For example: "C:\Users\[user name]\Documents\Attachmate\Reflection\filename.rd3x".

    Set frame = app.GetObject("Frame")

    Set terminal = app.CreateControl("[filepath]")

    Set view = frame.CreateView(terminal)