OLE Automation

See Also52R6YJ2

What is OLE Automation?

OLE Automation is an industry standard that applications use to expose their OLE objects to development tools, macro languages, and other containers that support OLE Automation.  For example, a spreadsheet application may expose a worksheet, chart, cell, or range of cellsall as different types of objects.  A word processor might expose objects such as application, paragraph, sentence, bookmark, or selection.

When an application supports OLE Automation, the objects it exposes can be accessed by Visual Basic.  You use Visual Basic to manipulate these objects by invoking methods on the object, or by getting and setting the objects properties, just as you would with the objects in Visual Basic.  For example, if you created an OLE Automation object named MyObj, you might write code such as this to manipulate the object:

' Enter text in the object.
MyObj.Insert "Hello, world."
' Format the text as bold.
MyObj.Bold
' Save the object to a file.
MyObj.SaveAs  "C:\WORDPROC\DOCUMENTS\TESTOBJ.DOC"

 

The properties and methods an object supports are defined by the application that created the object.  See that application's documentation for details on the properties and methods it supports.

Accessing an object

The following functions and properties allow you to access an OLE Automation object:

Name                                     Description

 

CreateObject Function           Creates a new object of a specified type.

GetObject Function                Retrieves an object from a file.

Object Property                      Specifies the object in an OLE control.

 

 

Distribution Note

When you create and distribute applications that use OLE Automation, you should install the files COMPOBJ.DLL, OLE2.REG, OLE2.DLL, OLE2CONV.DLL, OLE2DISP.DLL, OLE2NLS.DLL, OLE2PROX.DLL, STORAGE.DLL, and VBOA300.DLL in the customers Microsoft Windows \SYSTEM directory.

You also need to make sure OLE 2.0 is registered on the users machine and that SHARE.EXE is installed in the users AUTOEXEC.BAT file (SHARE.EXE is not required if the user is running Microsoft Windows for Workgroups).  Use the SetupWizard to create distribution disks that do this.

For more information on the SetupWizard and on distributing applications, see Chapter 25, Distributing Your Applications, in the Programmer's Guide or search Help for Setup Kit.  For more information on distributing OLE applications, see Chapter 22, Object Linking and Embedding (OLE), in the Programmer's Guide.

 


See Also

Help:

CreateObject Function0M4P7F

GetObject FunctionTLKUVF

Object Property1MHI551

OLE Control2HQDVVU

Set StatementLANSET

 

Programmer's Guide:

Chapter 22, "Object Linking and Embedding (OLE)"

Chapter 23, "Programming Other Applications' Objects"

Chapter 25, "Distributing Your Applications"