OLE Automation
   HOME

TheInfoList



OR:

In Microsoft Windows applications programming, OLE Automation (later renamed to simply Automation) is an inter-process communication mechanism created by
Microsoft Microsoft Corporation is an American multinational technology corporation producing computer software, consumer electronics, personal computers, and related services headquartered at the Microsoft Redmond campus located in Redmond, Washin ...
. It is based on a subset of Component Object Model (COM) that was intended for use by
scripting languages A scripting language or script language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. Scripting languages are usually interpreted at runtime rather than compiled. A scripting ...
– originally Visual Basic – but now is used by several languages on Windows. All automation objects are required to implement the
IDispatch IDispatch is the interface that exposes the OLE Automation protocol. Extending IUnknown, it is one of the standard interfaces that can be exposed by COM objects. COM distinguishes between three interface types: ''custom'' that are VTABLE-based I ...
interface. It provides an infrastructure whereby applications called ''automation controllers'' can access and manipulate (i.e. set properties of or call methods on) shared ''automation objects'' that are exported by other applications. It supersedes
Dynamic Data Exchange In computing, Dynamic Data Exchange (DDE) is a technology for interprocess communication used in early versions of Microsoft Windows and OS/2. DDE allows programs to manipulate objects provided by other programs, and respond to user actions affec ...
(DDE), an older mechanism for applications to control one another. As with DDE, in OLE Automation the automation controller is the "client" and the application exporting the automation objects is the "server". Contrary to its name, automation objects do not necessarily use Microsoft OLE, although some Automation objects can be used in OLE environments. The confusion has its roots in Microsoft's earlier definition of OLE, which was previously more or less a synonym of COM.


Advantages and limitations

To ensure interoperability, automation interfaces are limited to use a subset of all COM types. Specifically, automation interfaces must use SAFEARRAY instead of raw COM arrays. Automation-compatible COM servers can, however, rely on the in-built OLE marshalling implementation. This avoids the need for additional proxy/stub projects for marshalling out-of-process.


Usage

Automation was designed with the ease of scripting in mind, so controllers often provide languages such as
Visual Basic for Applications Visual Basic for Applications (VBA) is an implementation of Microsoft's event-driven programming language Visual Basic 6.0 built into most desktop Microsoft Office applications. Although based on pre-.NET Visual Basic, which is no longer support ...
to end users, allowing them to control automation objects via scripts. Automation objects are often written in conventional languages such as
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
, where C++ attributes can be used to simplify development, Languages such as
Visual Basic Visual Basic is a name for a family of programming languages from Microsoft. It may refer to: * Visual Basic .NET (now simply referred to as "Visual Basic"), the current version of Visual Basic launched in 2002 which runs on .NET * Visual Basic ( ...
and
Borland Delphi Delphi is a general-purpose programming language and a software product that uses the Delphi dialect of the Object Pascal programming language and provides an integrated development environment (IDE) for rapid application development of desktop, ...
also provides a convenient syntax for Automation which hides the complexity of the underlying implementation.


Type libraries

In order to automate an application, the developer of an automation controller must know the object model that is employed by the target application exporting activation objects. — despite the title, the article discusses
JScript JScript is Microsoft's legacy dialect of the ECMAScript standard that is used in Microsoft's Internet Explorer 11 and older. JScript is implemented as an Active Scripting engine. This means that it can be "plugged in" to OLE Automation applic ...
rather than
JavaScript JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of websites use JavaScript on the client side for webpage behavior, of ...
This requires that the developer of the target application publicly document its object model. Development of automation controllers without knowledge of the target application's object model is "difficult to impossible". Due to these complications, Automation components are usually provided with ''type libraries'', which contain metadata about classes, interfaces and other features exposed by an object library. Interfaces are described in Microsoft Interface Definition Language. Type libraries can be viewed using various tools, such as the Microsoft OLE/COM Object Viewer (oleview.exe, part of the
Microsoft Platform SDK Microsoft Windows SDK, and its predecessors Platform SDK, and .NET Framework SDK, are software development kits (SDKs) from Microsoft that contain documentation, header files, libraries, samples and tools required to develop applications for Micr ...
) or the Object Browser in Visual Basic (up to version 6) and Visual Studio .NET. Type libraries are used to generate
Proxy pattern In computer programming, the proxy pattern is a software design pattern. A ''proxy'', in its most general form, is a class functioning as an interface to something else. The proxy could interface to anything: a network connection, a large object in ...
/ stub code for interoperating between COM and other platforms, such as Microsoft .NET and
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mos ...
. For instance, the .NET Framework SDK includes tools that can generate a proxy .NET DLL to access Automation objects using both early binding (with information about interfaces extracted from a type library) and late binding (via IDispatch, mapped to the .NET Reflection API), with the built-in .NET-to-COM bridge called COM Interop. While Java lacks built-in COM support, toolsets like
JACOB Jacob (; ; ar, يَعْقُوب, Yaʿqūb; gr, Ἰακώβ, Iakṓb), later given the name Israel, is regarded as a patriarch of the Israelites and is an important figure in Abrahamic religions, such as Judaism, Christianity, and Islam. J ...
and jSegue can generate proxy source code (consisting of two parts, a set of Java classes and a
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
source for a
Java Native Interface In software design, the Java Native Interface (JNI) is a foreign function interface programming framework that enables Java code running in a Java virtual machine (JVM) to call and be called by native applications (programs specific to a hardwa ...
DLL) from type libraries. These solutions only work on Windows. Another Java based j-Interop library which enables interoperability with COM components without
JNI In software design, the Java Native Interface (JNI) is a foreign function interface programming software framework, framework that enables Java (programming language), Java code running in a Java virtual machine (JVM) to call and be called by n ...
, using DCOM wire protocol (MSRPC) and works on non-Windows platforms also. Microsoft has publicly documented the object model of all of the applications in
Microsoft Office Microsoft Office, or simply Office, is the former name of a family of client software, server software, and services developed by Microsoft. It was first announced by Bill Gates on August 1, 1988, at COMDEX in Las Vegas. Initially a marketi ...
, and some other software developers have also documented the object models of their applications. Object models are presented to automation controllers as type libraries, with their interfaces described in ODL.


Language support

Automation is available for a variety of languages, including, but not limited to: *
ABAP ABAP (Advanced Business Application Programming, originally ''Allgemeiner Berichts-Aufbereitungs-Prozessor'', German for "general report preparation processor") is a high-level programming language created by the German software company SAP SE. ...
* C *
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
(with Compiler COM Support, or with libraries like MFC or ATL) * C# *
Visual Basic Visual Basic is a name for a family of programming languages from Microsoft. It may refer to: * Visual Basic .NET (now simply referred to as "Visual Basic"), the current version of Visual Basic launched in 2002 which runs on .NET * Visual Basic ( ...
and
Visual Basic for Applications Visual Basic for Applications (VBA) is an implementation of Microsoft's event-driven programming language Visual Basic 6.0 built into most desktop Microsoft Office applications. Although based on pre-.NET Visual Basic, which is no longer support ...
*
Visual FoxPro Visual FoxPro is a Microsoft data-centric procedural programming language with object-oriented programming (OOP) features. It was derived from FoxPro (originally known as FoxBASE) which was developed by Fox Software beginning in 1984. Fox Techn ...
* dBASE (via OleAutoClient class) * Delphi * Microsoft .NET languages * APL (most Windows versions) *
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mos ...
(only with third-party tools) *
JScript JScript is Microsoft's legacy dialect of the ECMAScript standard that is used in Microsoft's Internet Explorer 11 and older. JScript is implemented as an Active Scripting engine. This means that it can be "plugged in" to OLE Automation applic ...
and
VBScript VBScript (''"Microsoft Visual Basic Scripting Edition"'') is an Active Scripting language developed by Microsoft that is modeled on Visual Basic. It allows Microsoft Windows system administrators to generate powerful tools for managing computers ...
* Open Object Rexx *
Perl Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offic ...
*
PHP PHP is a general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementation is now produced by The PHP Group. ...
*
PowerBuilder PowerBuilder is an integrated development environment owned by SAP since the acquisition of Sybase in 2010. On July 5, 2016, SAP and Appeon entered into an agreement whereby Appeon, an independent company, would be responsible for developing, se ...
*
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
*
Ruby A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called ...
(via the 'win32ole' library included in the standard Ruby 1.8.x or later distribution) *
Tcl TCL or Tcl or TCLs may refer to: Business * TCL Technology, a Chinese consumer electronics and appliance company **TCL Electronics, a subsidiary of TCL Technology * Texas Collegiate League, a collegiate baseball league * Trade Centre Limited ...
* Visual DataFlex *
WinBatch This is a list of notable programming languages, grouped by type. There is no overarching classification scheme for programming languages. Thus, in many cases, a language is listed under multiple headings (in this regard, see " Multiparadigm lan ...


See also

*
ActiveX ActiveX is a deprecated software framework created by Microsoft that adapts its earlier Component Object Model (COM) and Object Linking and Embedding (OLE) technologies for content downloaded from a network, particularly from the World Wide We ...
* Active Scripting *
Object Linking and Embedding Object Linking & Embedding (OLE) is a proprietary technology developed by Microsoft that allows embedding and linking to documents and other objects. For developers, it brought OLE Control Extension (OCX), a way to develop and use custom user i ...
(OLE) * Component Object Model (COM)


References


Further reading

* * * * — full printed documentation of the object model of Microsoft Office


External links


OLE Automation
General paper on the introduction and problems implementing OLE.
VOLE - A Neat C++ COM/Automation Driver
— an open-source, compiler-independent C++ COM Automation driver library, for use when having to drive IDispatch directly. VOLE is highly robust, fully encapsulates all "low-level" aspects of IDispatch, and is very flexible, taking and returning normal C++ types. {{Microsoft Windows components Object-oriented programming Microsoft application programming interfaces