Reflection Desktop VBA Guide
Key Concepts / Using Extra! and Legacy Reflection Macros
In This Topic
    Using Extra! and Legacy Reflection Macros
    In This Topic

    You can run Extra! or legacy Reflection macros in Reflection. You can also use tools provided by Reflection to edit Extra! Basic macros, legacy Reflection Basic macros, and legacy Reflection VBA macros.

    Some properties and methods are not supported. If the macro contains unsupported objects, its functionality may be limited or it may not run.

    Running Extra! and Legacy Reflection Macros

    Editing Legacy Reflection Macros

    Editing Extra! Macros

    Running Extra! and Legacy Reflection Macros

    You can open a settings file in the workspace to run the macros it contains, or you can run macros from an external file. Reflection supports the following macro file formats:

    You can run RCL scripts only when a VT session document is active in the workspace.

    To run a legacy Reflection macro in a settings or session file

    Note: Legacy macro options are available only if compatibility features are installed.
    1. Open the legacy settings file in Reflection.
    2. On the Session ribbon, from the Macros group, click Run Macro.
    3. From the Run Macro dialog box, select Legacy Reflection Macro in This File.
    4. In the Macros dialog, select the macro name and click Run.
      Note: These macros include legacy settings files (.rsf, .r2w, or .r4w) and session documents (.rd3x, .rd5x, .rdox) that were previously converted from settings files.

    To run a legacy macro from an external file

    Note: Legacy macro options are available only if compatibility features are installed.
    1. On the Reflection button, select Reflection Workspace Settings.
    2. Under Trust Center, select Set up API and Macro Security.
    3. In the Legacy API Preference list, select Reflection or Extra!.
    4. Close the workspace and then reopen it.
    5. If your legacy macro was created in Reflection 10.x or earlier, open and save it in Reflection 14.x.
    6. Open a session.
    7. On the Session ribbon, from the Macros group, click Run Macro.
    8. From the Run Macro dialog box, select Legacy Reflection Macro in Another File, Legacy RB Macro, or Extra! macro.
    9. Browse to the macro file that you want to run and click OK.

    Migrating Legacy Reflection IBM 3270 SharedMacros.rsf files to Reflection Desktop

     If you have used SharedMacros files in legacy Reflection products, you can migrate these files by simply opening and saving them in Reflection Desktop.  

    However, in some cases, when you migrate an IBM (.rsf) SharedMacros session file that you intend to use for IBM 3270 sessions, you may find that the file can only be saved as an IBM 5250 (.rd5x) file. In these cases, use the following process to convert these files.

    A legacy Reflection .rsf file used for IBM 3270 sessions is saved as an IBM 5250 file only if the .rsf file does not contain enough information for Reflection to determine the session type. If Reflection cannot determine the session type, it defaults to IBM 5250.  

    To convert a SharedMacros.rsf file to a Reflection Desktop IBM 3270 (.rd3x) file

    1. Open the legacy SharedMacros.rsf file in Reflection and save it as an IBM 5250 (.rd5x) file.
    2. With the SharedMacros.rd5x file open, create a new 3270 terminal session. 
    3. On the Macros tab, select Visual Basic to open the Visual Basic editor.
    4. In the Projects panel, drag the necessary VBA code from the SharedMacros.rd5x terminal session project into the newly created 3270 terminal session project. 
    5. Save the session as SharedMacros.rd3x.

    Editing Legacy Reflection Macros

    You can edit legacy Reflection macros in the Visual Basic Editor. However, some Session methods and properties are no longer supported.

    If you are editing a legacy VBA macro, you can use the Visual Basic editor to modify the macro.

    If you are editing a Reflection Basic macro:

    Before you distribute any type of legacy macro, review the Unsupported Reflection Session Methods and Properties and remove any references to unsupported objects that throw exceptions.

    Note: For each legacy document, Reflection creates an additional VBA project for the supported legacy API. This legacy API VBA project includes a ThisSession object, which provides backward compatibility for legacy macros. (You can view the legacy API VBA project in the Project Explorer window of the Visual Basic Editor.)

    Editing Extra! Macros

    If you need to make changes to your Extra! macros (.ebm), you can edit them using the Extra! Basic Editor.

    Then, edit the HostOptions properties in the macro to make the macro work with Reflection.

    Before you distribute any type of legacy macro, review the Unsupported Extra! Methods and Properties and remove any references to unsupported objects that throw exceptions.

    Edit HostOptions Properties

    If your macro uses the HostOptions object, you will need to edit the HostOptions properties.

    Extra! macros and Visual Basic applications that contain parameterized properties cause an error to occur in Reflection. When you run the macro or application, the HostOptions object returns the error "Method or property not found" if it encounters one of the following parameterized properties: AttributeForeground, AttributeBackground, or Color.

    Reflection is based on C# and doesn't support parameterized properties; therefore, statements that get and set these properties will have no effect. To avoid this problem, replace the parameterized properties with an equivalent form.

    To edit the property

    1. Start the Extra! Basic Editor.
    2. Open the macro.
    3. Replace the AttributeForeground, AttributeBackground, and Color properties using one of the following equivalent forms:
      • HostOptions.set_[property] x, y
      • y = HostOptions.get_[property]

      For example, change

      HostOptions.AttributeForeground(x) = y

      to

      HostOptions.set_AttributeForeground x, y

      -or-

      y = HostOptions.get_Attribute Foreground x

     

    See Also