VanDyke Software

Scripting Examples


Integrating with Microsoft Excel

Example 1: Excel Spreadsheets – Adding, Copying, and Renaming Sheets

This example script, ExcelSpreadsheets-AddingCopyingRenamingSheets.vbs.txt, demonstrates how to add, rename, and copy an Excel worksheet. This script also demonstrates one way to see whether a sheet already exists with the specified name, which is needed because trying to rename a sheet to an existing sheet's name causes an error.

Example 2: Excel Spreadsheets – Reading and Writing

This example script, ExcelSpreadsheets-ReadingAndWriting.vbs.txt, shows how to read (and write) data from (and to) an Excel spreadsheet using VBScript running within SecureCRT. This specific example connects one by one to hosts (IP address is read in from column "A") and port (read in from column "B") using a connection protocol (read in from column "C") authenticating with username and password (read in from columns "D" and "E"). The command sh config is run on the host (unless the value in column "F" is "No"), and then writes the date and time of the activity as well as the results of the command in columns "G" and "H", respectively.

Example 3: Excel Spreadsheets – Searching and Lookups

Two example scripts (ExcelSpreadsheets-SearchingAndLookups.vbs.txt and ExcelSpreadsheets-SearchingAndLookup-GatewayLogins.vbs.txt) show how to search for (look up) data within an Excel spreadsheet using VBScript running within SecureCRT and read data from other cells within the row that contained the data that was found.

Example 4: Launch SecureCRT from Excel Spreadsheet Using On-the-Fly Script

The following three examples:

show how, from within an Excel macro, you can gather information from the current row (the active row) and use that information to create an on-the-fly VBScript code file in a temporary location. Once the script file is created, SecureCRT is launched with the /SCRIPT command line option as well as /ARG elements so that the script SecureCRT is told to run knows (a) which protocol to use (Telnet/SSH2/SSH1), (b) what hostname to connect to, (c) what username to authenticate as, and (d) what password to use for authentication. Once the SecureCRT instance that was launched has terminated, the temporary script file is deleted.

Here is an image of the spreadsheet for the RunSecureCRTWithAScriptCreatedFromExcelMacro.cls.txt example:

Here is an image of the spreadsheet for the RunSecureCRTWithAScriptCreatedFromExcelMacro_JumpHost+Enable.cls.txt example:


Example Scripts

ExcelSpreadsheets-AddingCopyingRenamingSheets.vbs.txt (6.6 KB)
ExcelSpreadsheets-ReadingAndWriting.vbs.txt (10.7 KB)
ExcelSpreadsheets-SearchingAndLookups.vbs.txt (18.1 KB)
ExcelSpreadsheets-SearchingAndLookup-GatewayLogins.vbs.txt (20.2 KB)
RunSecureCRTWithAScriptCreatedFromExcelMacro.cls.txt (4.6 KB)
RunSecureCRTWithAScriptCreatedFromExcelMacro_JumpHost+Enable.cls.txt (4.0 KB)
ConnectToSecondaryHost_via_JumpHost_ShellDriverExcel.bas.txt (9.8 KB)

VanDyke Software uses cookies to give you the best online experience. Before continuing to use this site, please confirm that you agree to our use of cookies. Please see our Cookie Usage for details.