Some legacy VBA methods require a Session object when run with Reflection Desktop

  • 7023037
  • 31-May-2018
  • 03-Jul-2018

Environment

Reflection Desktop (including Pro, for IBM, or for UNIX and OpenVMS) 16.0 or higher
Reflection 2014
Reflection Pro 2014
Reflection for IBM 2014
Reflection for UNIX and OpenVMS 2014
Reflection for IBM 2011
Reflection for UNIX and OpenVMS 2011
Reflection Standard Suite 2011

Situation

Some legacy VBA methods require a Session object to proceed the method when run with Reflection Desktop legacy-VBA but not when run in Reflection version 14.  When the Session / ThisSession object is not used in Reflection Desktop and the macro is run without the object, a new Reflection COM session object is created for which the terminal object is null, which in turn creates a new blank and non-connected host session.

An example is the legacy-VBA calls to the .GetSaveAsFilename method for logging to a file in a VT session. Here is a short sample macro:

        Sub PrintScreentoFile()
                With Session
                        ' following line works with Reflection 14 and fails with Reflection Desktop 16.0
                       Myfile = GetSaveAsFilename(.PrintToFile, "Text files (*.txt),*.txt", 1, "Select a log file", "Save")

                       ' following line works with both Reflection 14 and Reflection Desktop 16.0
                       ' Myfile = .GetSaveAsFilename(.PrintToFile, "Text files (*.txt),*.txt", 1, "Select a log file", "Save")
                End With
        End Sub

When running this macro with Reflection 14 it will use the existing open host session and bring up a file dialog box to select a logging file.  When running this macro with Reflection Desktop 16.0 it will open a new host session and bring up a file dialog box to select a logging file on top of this session.  To make this macro work in Reflection Desktop 16.0, use the . (dot) in front of the GetSaveAsFilename as shown in the commented out line above.

Resolution

If using Reflection Desktop 16.0:
        Upgrade to Reflection Desktop 16.0 SP1 HF17 or higher (16.0.478)
If using Reflection Desktop 16.1:
        Upgrade to Reflection Desktop 16.1 SP1 or higher

There are 4 visible changes made to Reflection Desktop for this issue:

1. When legacy Reflection version 14 host sessions (.r2w, .r4w, .rsf files) are now opened in Reflection Desktop, the Session object is automatically added in front of methods in LegacyProject section where it is missing and required.  This is a one time process.

2. When Reflection Desktop host sessions (.rd3x, .rd5x, .rdox files) are opened in Reflection Desktop, the Session object is automatically added in front of methods where it is missing and required in the LegacyProject section.  This is a one time process.

3. When Reflection Desktop host sessions (.rd3x, .rd5x, .rdox files) or legacy Reflection version 14 host sessions (.r2w, .r4w, .rsf files) are opened in Reflection Desktop, and the session document is marked for Read Only, the Session object is automatically added each time (because it can not be saved) in front of methods where it is missing and required in the LegacyProject section.  This happens every time a Host session file is opened.

4. When the Session object is automatically added in front of methods where it is missing and required in the LegacyProject section (items 1-2 above), a VBA Comment is added to indicate the changes made.    This is a one time process.

A HotFix (HF) for Reflection Desktop is a cumulatively built product update, intended for limited distribution, which addresses specific customer issues and enhancement requests; outside the regular Development release cycle. It is only available to Micro Focus customers with current software support and maintenance contracts, and only after contacting Micro Focus Customer Support directly.  A HotFix undergoes limited stability and quality testing and is intended for quick release to address specific product issues and should not be deployed to production environments without thorough testing.  It is recommended to upgrade to a full-release or a Service Pack version of Reflection Desktop when it becomes available.

Workaround:

Add the .(dot) and the Session object in front of the method, like Session.GetSaveAsFilename shown below:
       Sub PrintScreentoFile()
               With Session
                    Myfile = .GetSaveAsFilename(.PrintToFile, "Text files (*.txt),*.txt", 1, "Select a log file", "Save")
               End With
       End Sub