Recorded VBA macro may not play back properly due to duplicate blocks of recorded macro code

  • 7024864
  • 14-Oct-2020
  • 02-Nov-2020

Environment

Reflection Desktop (including Pro, for IBM, or for UNIX and OpenVMS) 16.0 or higher

Situation

Visual Basic for Applications (VBA) macros which are recorded by a user within Reflection Desktop, may not always play back properly due to incorrectly added duplicate blocks of recorded macro code.  This will typically come about if the end-user is recording a VBA macro and inadvertently types really fast, or “types ahead” in a 3270 or VT session, while connected to a "slower" Host system.  The VBA macro recorder may insert additional duplicate blocks of code in the recorded VBA macro, preventing the macro from running correctly. such as stopping unexpectedly during playback.  Depending on the speed at which the Host presents each screen of data, the speed at which the Host updates the screen, and the speed at which the user types, will determine how the macro is formed.  There is the possibility of differently recorded macros occurring, some which work and some which fail.

Resolution

If a recorded VBA macro in Reflection Desktop is failing to run properly during playback, perform the following:

1. Delete and re-record the macro using slow and deliberate steps.  Plan in advance of the recording, what steps are going to be followed, what keys will be pressed, and what host screens are anticipated. While recording the macro, after pressing a key to submit data to the host, wait for the next host screen to fully appear (sometimes even waiting a few extra seconds) before pressing the next keys.  Recording a macro slowly and carefully, does not make the macro run with reduced performance, as macros will always run at the fastest speed possible during playback.  Recording a well thought out and planned macro will lead to the best results.

2. Re-record the macro using the Custom Setting of "MacroReorderVersion1="true".  This value will make the macro recording engine switch to using a HostSettle time parameter in the recorded macro.  This could result in a macro which will correctly capture host session keyboard input while the host screen is updating. The potential drawback to this approach is that the macro may be slower in performance at runtime.  See the Additional Information field below for more details on adding this Custom Setting.

3. Manually edit the macro in the VBA editor to remove duplicate blocks of code.  This step will require knowledge of the VBA programming language and syntax, as well as knowledge of the host screens being navigated, and thus is only for more experienced users.


Additional Information

To add a Custom Setting in Reflection Desktop::

1. Open the Reflection Workspace.

2. Click the Document Settings button.

3. Click the >> symbol after “Reflection Workspace Settings”.

4. Select “Custom Settings” from the list.

5. Click “Configure Custom Settings”.

6. Place the Custom Setting of "MacroReorderVersion1" in the “Name” field.

7. Put the text of "true" in the Value field for the custom setting.

8. Click OK.

9. Close the Reflection Workspace.

10. Re-open the Reflection Workspace and Host session and re-record the macro.