Reflection Desktop VBA Guide
HowTos / Use Connection Macros
In This Topic
    Use Connection Macros
    In This Topic

    Using macros to establish host connections can be quite useful, particularly if you connect to multiple hosts, or use different connection settings.

    If you use OpenSystems hosts, you may also want to use macros to configure your connection settings, especially if you use automation to create Reflection session documents. (If you save the correct host connection information in the session document that contains your macros, you don't need to change connection settings programmatically.)

    When using macros to configure settings, use these best practices:

    Note: If you assign values that are invalid to the properties of the ConnectionSettings object, or you try to set a property that can't be changed when the connection is open, errors can result. Include an error-handling routine in your macro to trap and deal with these errors (for example, by displaying a message box). You can retrieve the error text using the ConnectionErrorMessage property.

     

    This sample retrieves the type of Open Systems connection that is used and displays it in a message box.

    This sample applies only to Open Systems terminals.

    To run this sample

    1. In an Open Systems session, open the Visual Basic Editor and then enter the sample code in the ThisTerminal code window.
      Running a Connection Macro
      Copy Code
      Private Sub Terminal_Connected(ByVal sender As Variant, ByVal ConnectionID As Long, ByVal connnectionType As Attachmate_Reflection_Objects_Emulation_OpenSystems.ConnectionTypeOption, ByVal connectionSettings As Variant)
          Dim how As ConnectionTypeOption
         
          Dim msg As String
          how = ThisTerminal.connectionType
       
          If how = ConnectionTypeOption.ConnectionTypeOption_None Then
              msg = "There is no connection currently configured."
          End If
          If how = ConnectionTypeOption.ConnectionTypeOption_BestNetwork Then
              msg = "The current Connection Type is" & "BestNetwork"
          End If
          If how = ConnectionTypeOption.ConnectionTypeOption_COMSerialPort Then
              msg = "The current Connection Type is " & "COMSerialPort"
          End If
          If how = ConnectionTypeOption.ConnectionTypeOption_Modem Then
              msg = "The current Connection Type is " & "Modem"
          End If
          If how = ConnectionTypeOption.ConnectionTypeOption_Rlogin Then
              msg = "The current Connection Type is " & "RLogin"
          End If
          If how = ConnectionTypeOption.ConnectionTypeOption_SecureShell Then
              msg = "The current Connection Type is " & "SecureShell"
          End If
          If how = ConnectionTypeOption.ConnectionTypeOption_Telnet Then
              msg = "The current Connection Type is " & "Telnet"
          End If
          If how = ConnectionTypeOption.ConnectionTypeOption_VT_MGR Then
              msg = "The current Connection Type is " & "VT_MGR"
          End If
          MsgBox (msg)
      End Sub
      
    2. Disconnect the session and then reconnect to display the connection type.
    See Also