Configuring Reflection 14.x to Run a Visual Basic for Applications Macro on Startup

  • 7021649
  • 04-Apr-2002
  • 01-Apr-2018

Environment

Reflection for UNIX and OpenVMS version 12.0 through 14.x
Reflection for HP version 12.0 through 14.x

Situation

Macros can be used to simplify the process of configuring Reflection and connecting to a host. This technical note lists two options and gives an example of a more complex VBA project that uses a VBA UserForm.

Resolution

Selecting a Method

First, determine if you want to:

  • Associate a VBA macro with a Reflection settings file so that when the user accesses the file (icon/button) the user will be connected to a pre-specified host. See "Simple Login Scripts."
  • Create a VBA project that gathers information or configures Reflection before a connection is made. Examples include reading from an INI file; configuring Reflection settings, events, menus, toolbars or hotspots; and displaying a VBA UserForm to gather information from the user. See "Complex VBA Projects."

Simple Login Scripts

You can configure Reflection so that a simple login script will run any time a user connects to a host. You can configure this option in one of two ways:

  • Record a login using the macro recorder. When you stop recording, in the Stop Recording dialog box, the "Make this the connect macro" option is selected by default.
  • Create your own macro and then configure it to be the connect macro. To do this, go to Connection > Connection Setup > Connect Macro and browse to your macro.

Note: Connect macros run immediately after Reflection has successfully made a connection to the host. Therefore, they should not include information critical to creating the connection itself.

Complex VBA Projects

When you write a more complex project, it is often useful to have the first macro run only when Reflection starts, rather than when Reflection connects to the host. One example of using this method would be a Visual Basic for Applications' UserForm that gathers information from the user before connecting to the host. To configure Reflection not to connect on startup, use the When Reflection Starts event. The following example demonstrates this approach.

Example

Imagine that you have created a UserForm named frmHealthTrac that thousands of nurses use to access their host applications.

To make this form the starting point of your project, create a macro as follows:

Sub Start
FrmHealthTrac.Show
End Sub

Follow these steps to configure Reflection to run your macro when Reflection starts.

  1. In Reflection, click Setup > View Settings.
  2. Type startup action in the search field.
  3. Click the drop-down box and select "Load Saved Settings but Do Not Connect."
  4. Click OK.
  5. To configure your event, click Setup > Events.
  6. Click New. Reflection's default event is "When Reflection Starts."
  7. On the Action line select the Macro radio button, and then click Browse.
  8. Select your Start macro and click OK.
  9. Save your settings.

Now Reflection will start without a connection. The Start macro will run, and the HealthTrac form will display on the screen.

Additional Information

Legacy KB ID

This document was originally published as Attachmate Technical Note 1631.