Partilhar via


Design of an OLE Application

Automation-enabled applications and COM components can act as Automation servers, clients, or both. Components that act as servers can provide objects to another application; components that act as clients can create objects.

You can easily incorporate the power and flexibility of applications, such as Microsoft Excel and Word, in your Visual FoxPro applications. Because Visual FoxPro also acts as a server, you can also provide functionality that can be integrated into solution packages based around Microsoft Office or other COM components.

Insertable OLE objects come from OLE-capable applications such as Microsoft Excel and Word. Such objects include Word documents and Excel worksheets. On forms, you can link or embed these objects using the OLE Container control, and you can store such objects in General fields of a table, displaying them in your forms with the OLE Bound control.

In a Visual FoxPro application, you can use OLE and ActiveX technology in many ways. Before you create an application, consider the ways you can use these technologies.

Linking or Embedding OLE Objects

You can embed or link files from other Windows applications in your tables and forms. For example, you can embed or link a Word document in a General field of a table, and you can embed or link an Excel worksheet on a form.

The difference between embedding and linking lies in where the data is stored. Embedding stores the data in the table or form, whereas linking does not. For example, when you embed an Excel worksheet on a form, the form contains a copy of the worksheet. When you link, however, the form contains only a reference to the worksheet — not the worksheet itself.

Both embedded and linked data start off with the original contents of the server file.

But when the original file is changed, linked data is automatically updated to reflect the change, whereas embedded data is not:

Linked data updated in a form

Embedded data is not necessarily static, though. Both embedded and linked data can be displayed, changed, and manipulated interactively and programmatically in Visual FoxPro.

Adding Bound or Unbound OLE Objects

On a form or in a report, you can create objects that are bound to General fields in tables. Such objects are called bound OLE objects and you use them to display the contents of OLE objects in General fields. You create bound OLE objects by using the OLE Bound control on the Form Controls toolbar. Alternatively, you create unbound OLE objects by using the OLE Container control. An unbound OLE object is not connected to a General field in a table.

See Also

Adding OLE Objects to Your Applications | Adding OLE | Using ActiveX Controls | Manipulation of Objects with Automation | The Subclassing of Objects