Embedding and linking allows the user to insert objects, created by some other application, directly into a document—without having to leave the application being used to create the document.
Embedding an object is simple: the user selects from a list of objects (for example, a picture, a range of spreadsheet cells, or a sound recording). Then the application that can create the object starts automatically, giving the user the opportunity to create or modify the object for insertion. When the user quits the application that created the object, the modified object automatically appears in the document of the current application.
Linking objects means the user inserts a link to the file that contains the source of the object. Then, any time the source object changes, the linked object in the user's document is updated to reflect the change at the source.
To illustrate the concept of embedded objects in more detail, consider a situation where an author needs to write a technical article and, in order to enhance it, needs to add objects created using one or more other applications. To accomplish this, the author begins work with a word processor, using it to lay out the pages and enter the majority of the text, to achieve an appearance similar to that shown in Figure 1.
Figure 1. An embedded object in a container document
To enhance the article with a logo of the company, the author places the insertion point where the logo is to appear and chooses the type of object to insert, using the Insert Object command. (For example, Figure 1 in the book you are now reading is an embedded object in the document used to prepare the camera-ready copy.)
Choosing the object type automatically starts the appropriate graphics application from within the word processor. Once in the graphics program, the author draws the logo (or imports it from a previously saved graphics file), then quits to return to the word processor. Quitting the graphics program causes the drawn logo to be automatically displayed in the document. In the sample document shown in Figure 1, the company logo, created with an OLE graphics program, is inserted as an embedded object.
Note While the following example focuses on a word processor document and a graphic objects, it can apply to any type of OLE application, document, and object.
As an embedded object, all data associated with the logo is included with the word processor document and will be saved as part of the document file. Figure 2 shows that the saved document file contains not only the object data in a form needed by the word processor to display the object, but also in the form that is native to the application that created it. The native data allows the object to be passed back to the creating application for possible changes. The embedded object also contains data that associates it directly to the creating application so that it is known which application provided the object and with what presentation data format it was created.
Figure 2. Data storage format for embedded objects
If, at some later time, the embedded object (the logo, in this case) needs to be modified, the author simply opens the word processor document, and double-clicks on the embedded object. This action starts the associated graphics program and displays the object using the embedded data previously stored in the word processor document. When the author finishes with the object and quits the graphics application, the object displayed in the word processor document is automatically updated to reflect the changes.
Prior to OLE, it was certainly possible to integrate text and graphics into a word processor document—the standard way was to use the cut, copy, and paste mechanism supported by the clipboard. However, if the copying and pasting had to be done back and forth many times, the process grew tedious and the room for human error increased. Now with OLE, the graphics can be pasted in once, and edited as many times as necessary with a simple double-click of the mouse.
Linked objects, although they may look the same to a casual user, differ greatly from embedded objects. The main difference between an embedded object and a linked object is in:
how it is inserted into the document
how it is later changed or updated
where the native data for the object is stored.
While embedded objects can be copied and pasted with the clipboard to insert them into a document, linked objects must be copied and pasted through the clipboard. Embedded objects are usually opened for edited by double-clicking the object to start the creating application; the changes are made and the creating application closes. This method can also apply to a linked object; however, linked objects are updated whenever the original file that the object is linked to is changed.
Figure 3 depicts the data storage format for a linked object. Unlike an embedded object that saves the native data to an object, linked objects store only the presentation data for the object along with the pathname of the source file that contains the original, native data.
Figure 3. Data storage format for linked objects
To illustrate object linking, suppose a word processor document needs to include data that is normally maintained in a spreadsheet. A range of spreadsheet cells in the original spreadsheet is pasted into the word processor document as a linked object. The word processor document then contains the data from the original spreadsheet file. A single cell or an entire spreadsheet can be linked. Each time the original spreadsheet is changed, the linked object in the word processing file can be updated, either automatically or manually, by the user's choice.
Figure 4 shows how the spreadsheet cells are linked to the word processor document. While the document contains the data necessary to display the contents of the cells, just as it would if they were an embedded object, it does not contain native data for the object. Native data is not necessary since any changes to the spreadsheet will be made by the spreadsheet program directly to its own file—the file to which the word processor document is linked.
To modify a linked object, such as the contents of the spreadsheet cells in the preceding example, the spreadsheet cells in the word processor document are double-clicked. This action starts the associated spreadsheet program and causes the spreadsheet application to open the linked file for editing.
Figure 4. A linked object in a container document
After the linked object is edited, saved, and the spreadsheet application is closed, the spreadsheet cells in the word processing document are updated immediately if the user has set the link up as an automatic link; or if the link will be updated later at the user's choice, the link is a manual link. Any other documents containing links to the changed object will have their copies of the object updated whenever those documents are opened and the command is given to update the linked object.
1.1.2.3 OLE and Audio-Visual Objects
So far, we've discussed OLE and how it enables the user to insert and edit objects, specifically graphics and spreadsheet data embedded in or linked to word processor documents. However, the use of OLE is not limited to inserting graphics and tabular data. With OLE, the user can also insert audio and visual types of objects. For example, the user could embed an audio object such as a digitally-recorded spoken message so that when the reader clicks the objects, the message plays through a speaker. For a document that provides "how to" instructions, OLE objects that play animation or video could be included.