Using Visual Basic for Applications (VBA)
Introductionto Visual Basic for Applications (VBA), explains what VBA is.
VBA Editor, describes how to access the VBA editor.
PwtPro Objects, Properties and Methods, describes how to view PwtPro objects, properties and methods.
A List of the VBA Commands, describes the available VBA commands.
An Example of VBA programming, describes how to create a dialog box that would facilitate making a connection with the host via PowerTerm Pro.
PowerTerm Pro VBA Sample Scripts, lists the PowerTerm Pro VBA sample scripts designed for performing frequent tasks and their required parameters.
Programming an Existent Script, describes how to create a VBA script from a existent PSL script.
Running VBA Scripts from the Command Line, describes how to run a VBA script from the command line.
PowerTerm Pro VBA Sample Project, describes how to view the PowerTerm Pro VBA Sample Project and what it consists of.
Introduction to Visual Basic for Applications (VBA)
Visual Basic for Applications is a powerful technology that lets you add programmability to your application.
VBA is an attractive alternative to the present PowerTerm scripting language(PSL). The main disadvantage with PSL was that editing was conducted in Notepad that was not comfortable to work with. PSL was unique to PowerTerm and therefore oneís previous programming knowledge could not be drawn upon to write a script. VBA is approaching acceptance as the industry standard. Visual Basic for Applications is common to many programming applications, including Microsoft Office 97 products. The programming knowledge acquired in any of these products will be immediately applicable to any other product that uses VBA. If you already have an application installed that uses VBA, PowerTerm Pro uses that component.
What Can You Do with VBA?
Automation is the key technology that makes individual Microsoft Office applications programmable. This technology allows a developer to use VBA code to create and control software objects exposed by any application, dynamic-link (DLL), or ActiveX control, which supports the appropriate programmatic interfaces.
The key to controlling an OLE automation application is a firm understanding of the applicationís object model. The object model is a hierarchy of objects that the application exposes. The application also exposes the objectís methods and properties with which the user works. It acts to describe the application to you, the developer. Each applicationís object model is different, and the amount of control you have over the application varies accordingly.
PowerTerm Pro enables you to write VBA scripts which can access and manipulate PowerTerm Pro objects and attributes.
Starting the VBA editor
1)From the Tools menu, click Macro.
Foronline help, press <shift>+<F2>.
By adding an object reference to your project, you expose the classís type library to the VBA environment, allowing the details of its class hierarchy to be displayed as you enter your code. By default, PowerTerm Pro is referenced by your project. You can confirm this by selecting References from the Tools menu.
Objects, Properties and Methods
The Visual Basic for Applications programming language is common across numerous enterprise applications. In addition to PowerTerm Pro, you can use VBA in Word, Excel, Access, PowerPoint and Outlook. Once you learn it, you can apply it to any of these. However, to work with an application, you need to learn about the objects it contains. In Word, you deal with documents, paragraphs and words. In Excel, you deal with workbooks, worksheets and ranges. In Access, you deal with databases, recordesets and fields. In PowerTerm Pro, you deal with Application, Session and Setup. Each application mentioned above has a clearly defined set of objects that are arranged according to the relationships between them This structure is referred to as the applicationís Object Model. The PowerTerm Pro Object Model is shown below:
In order to view the Object Model, open the Object Browser in the VBA Editor which displays the objects that are used in the application, their properties and methods which are the means in which the user can interact with the application PowerTerm Pro. The Object Browser is also helpful in viewing the objects of other applications with VBA incorporated in them.
Left-click on any item that appears in the right hand pane displays its definition in the bottom pane.