Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Visual Basic for Applications
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Automation== Interaction with the host application uses [[OLE Automation]]. Typically, the host application provides a [[data type|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. 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. 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. 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. VBA programs can be attached to a menu button, a [[macro (computer science)|macro]], a [[keyboard shortcut]], or an OLE/COM event, such as the opening of a document in the application. The language provides a user interface in the form of UserForms, which can host [[ActiveX]] controls for added functionality. [[Inter-process communication]] automation includes the [[Dynamic Data Exchange]] (DDE) and [[Real-time data|RealTimeData]] (RTD) which allows calling a [[Component Object Model]] (COM) automation server for dynamic or realtime financial or scientific data.<ref>{{cite web|url=https://support.microsoft.com/en-us/help/289150/how-to-set-up-and-use-the-rtd-function-in-excel|title=How to set up and use the RTD function in Excel|website=msdn.microsoft.com}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)