Create an SSH Session from Excel

You can use macros to configure SSH connections for new sessions.

This Microsoft Excel macro creates, configures, and connects to a new SSH terminal connection.


This sample applies only to Open Systems terminals.

To run this sample

  1. In Microsoft Excel, open a new worksheet and then open the VBA editor.
  2. In the VBA Editor for an Excel worksheet, select the project and then from the Tools menu, add references to these Micro Focus libraries:
  • Attachmate_Reflection_Objects
  • Attachmate_Reflection_Objects_Framework
  • Attachmate_Reflection_Objects_Emulation_OpenSystems
  1. Enter the following sample code in a Sheet object module.
    Create an SSH Session
    Copy Code
    Sub OpenSSHConnection()  
         Dim App As Attachmate_Reflection_Objects_Framework.ApplicationObject
         Dim Terminal As Attachmate_Reflection_Objects_Emulation_OpenSystems.Terminal
         Dim Frame As Attachmate_Reflection_Objects.Frame
         On Error Resume Next
         'Try to use the existing workspace
         Set App = GetObject("InfoConnect Workspace")
         On Error GoTo 0
         'Otherwise, Create New instance of InfoConnect
         If IsEmpty(App) Or (App Is Nothing) Then Set App = _
         With App
             Do While .IsInitialized = False
                 .Wait 200
             'Obtain the Frame Handle
             Set Frame = .GetObject("Frame")
             'Make it visible to the user
             Frame.Visible = True
         End With
         'Create an Open Systems control and immediately turn off autoconnect
         Set Terminal = App.CreateControl2("{BE835A80-CAB2-40d2-AFC0-6848E486BF58}")
         With Terminal
             .AutoConnect = False
            'Set the connection type
             .ConnectionType = ConnectionTypeOption_SecureShell
            'Set your hostname and other connection settings
             With .ConnectionSettingsSecureShell
                 .HostAddress = "hostName or IP Address"
                 .UserName = "admin"
             End With
         End With
         'Create a view for the terminal
         Set View = Frame.CreateView(Terminal)
         'Manually call connect because Auto is now disabled
     End Sub

  1. Set the values of the HostAddress and UserName properties and then press F5 to run the macro.


To set up scripts that automatically connect to sessions with SSH, see the following technical notes.

Automating SSH, SFTP, and SCP with Windows Scheduled Tasks (
Configuring InfoConnect for Public Key Authentication in Secure Shell Connections (


See Also