<P> Interaction with the host application uses OLE Automation . Typically, the host application provides a type library and application programming interface (API) documentation which document how VBA programs can interact with the application . This documentation can be examined from inside the VBA development environment using its Object Browser . </P> <P> Visual Basic for Applications programs which are written to use the OLE Automation interface of one application cannot be used to automate a different application, even if that application hosts the Visual Basic runtime, because the OLE Automation interfaces will be different . For example, a VBA program written to automate Microsoft Word cannot be used with a different word processor, even if that word processor hosts VBA . </P> <P> Conversely, multiple applications can be automated from the one host by creating Application objects within the VBA code . References to the different libraries must be created within the VBA client before any of the methods, objects, etc. become available to use in the application . This is achieved through what is referred to as Early or Late Binding . These application objects create the OLE link to the application when they are first created . Commands to the different applications must be done explicitly through these application objects in order to work correctly . </P> <P> As an example, VBA code written in Microsoft Access can establish references to the Excel, Word and Outlook libraries; this allows creating an application that--- for instance--- runs a query in Access, exports the results to Excel and analyzes them, and then formats the output as tables in a Word document or sends them as an Outlook email . </P>

What is vba and how does it work