Using the Office or Windows Clipboard to copy data from one application to another is simple, but both methods suffer from three major problems. First, if the data gets changed in the original application, the document containing the copy will become out of date. This has two consequences:
Second, what if you want to make changes to the copied data? You might be able to edit the data directly (if it's just text, for example), but more often than not, you'll need to fire up the original application, change the data there, and then copy the data again. However, problems can arise if you're not sure which application to use or if you're not sure which file contains the original data. Third, copying data between documents is often wasteful because you end up with multiple copies of the same data. You could cut the data from the original application and then paste it, but then there would be no easy way to edit the data using the original application. It would be nice if you didn't have to worry about the updating of your shared data. It would be nice if there were a system that would accomplish three goals:
Happily, the twin technologies of linking and embedding meet all three goals and add a few extra conveniences to the mix for good measure. Understanding Compound DocumentsA compound document is a document that contains, along with its native data, one or more objects that were created using other applications. The key point is that the compound document's native data and its objects can have entirely different data formats. For example, a Word document can include an Excel range object or a sound clip object. The container application doesn't need to know a thing about these alien data formats, either. All it has to know is the name of the server application that created the data and how to display the data. All this information (and more) is included free of charge as part of the object, so it's readily available to the container application. You create a compound document by either linking objects to the document or embedding objects in the document. The next three sections explain linking and embedding in more depth.
Understanding LinkingLinking is one of the methods you can use to insert an object into a file from a container application and thus create a compound document. In this case, the object includes only the following information:
Linking brings many advantages to the table, but three are most relevant to our purposes. First, the link lets the container application check the source document for changes. If it finds that the data has been modified, it can use the link to update the object automatically. For example, suppose you insert a linked Excel worksheet object into a Word document. If you revise some of the numbers in the worksheet sometime down the road, the object inside the document is automatically updated to reflect the new numbers. However, this updating is automatic only under certain conditions:
Second, because the object "knows" where to find both the server application and the source document, you can edit the object from within the container application. In most cases, double-clicking the object invokes the server and loads the appropriate source file. You can then edit the original data and exit the server application, and your object is, once again, updated automatically. Third, because the source data exists in a separate file, you can easily reuse the data in other compound documents, and you can edit the data directly from within the server application. Understanding EmbeddingOne of the problems associated with linking is that if you distribute the compound document, you also have to distribute the source document. Embedding solves this problem by inserting an object not only with the server's Registry information and the metafile for displaying the object, but also with the object's data. This way, everything you need to display and work with the object exists within the object itself. There's no need for a separate source file, so you can distribute the compound document knowing that the recipient will receive the data intact. In fact, embedding lets you create server objects from within the container application. If you're working with Word, for example, you can insert a new Excel worksheet object into your document. Windows will start Excel so that you can create the new object, but when you exit Excel, the object will exist only within the Word compound document. There will be no separate Excel file. Note that many applications can operate only as servers. This means that they aren't standalone applications and therefore have no way to create files on their own. They exist only to create objects for compound documents. Microsoft Office ships with several examples of these applications, including WordArt and Microsoft Graph. Should You Link or Embed?Perhaps the most confusing aspect of all this is determining whether you should link your objects or embed them. As you've seen, the major difference between linking and embedding is that a linked object stores only a pointer to its data, whereas an embedded object stores its own data internally. With this in mind, you should link your objects if any of the following situations apply:
Similarly, you should embed your objects if any of the following situations apply:
Linking an ObjectIf you have data you'd like to share between applications, and you think that linking is the best way to go, Windows gives you two methods: linking via the Clipboard and inserting a linked file. The next two sections discuss each method. Then I'll show you how to work with and maintain your links. Linking via the ClipboardAfter you've placed the data on the Clipboard, switch to the container application and position the cursor where you want the data to be pasted. Now select Edit, Paste Special to display the Paste Special dialog box, shown in Figure 6.3. Figure 6.3. Use the Paste Special dialog box to paste Clipboard data as a linked object.
The As box lists the various formats available for the data, but you can ignore most of them. To establish a link between the container and the server, you need to do two things:
If you'd like the data to appear as an icon in the container document, activate the Display as Icon check box. When you're ready, click OK to paste the linked object into the container. Figure 6.4 shows an Excel range pasted normally and as an icon. Figure 6.4. A linked Excel worksheet object displayed normally and as an icon.Inserting a File as a Linked ObjectInstead of pasting part of a document as a linked object, you might prefer to insert an entire file as a linked object. For example, if you insert a linked Excel workbook into a Word document, the container object will reflect any changes made to the original file, including data added or removed, global formatting adjustments, and so on. (Note, however, that in this case only the first worksheet is inserted.) Also, in certain situations you have no choice but to insert a file. For example, you can't insert part of a bitmap as a linked object; instead, you have to insert the entire file. Here are the basic steps to follow to insert a file as a linked object:
Managing LinksAll container applications that support object linking also give you some kind of method to manage document links. This involves updating a link so that the container displays the most recent changes, changing a link's source, determining how links are updated in the container, and breaking links you no longer need to maintain. In most container applications, you manage links by selecting Edit, Links to display the Links dialog box, which should be similar to the one shown in Figure 6.6 (this is the Links dialog box from Word). Figure 6.6. Container applications that support object linking have a Links dialog box that you can use to maintain the links.Following is a rundown of the basic link management chores you can perform:
Embedding an ObjectIf you prefer to embed an object instead of linking it, Windows gives you three methods to choose from (depending on the server application): the Clipboard, inserting a new embedded object, and inserting an embedded file. Embedding via the ClipboardTo embed data that's been placed on the Clipboard, switch to the container application, position the cursor where you want the data to be pasted, and select Edit, Paste Special. In the Paste Special dialog box that appears, you embed the data by doing two things:
Also, if you'd like the data to appear as an icon in the container document, activate the Display as Icon check box. When you're ready, click OK to embed the object in the container. Inserting a New Embedded ObjectIf the object you want to embed doesn't exist, and you don't need to create a separate file, Windows lets you insert the new object directly into the container application. Here's how it works:
Inserting an Embedded FileYou can insert an entire existing file (in contrast to an object within a file) as an embedded object. This is useful if you want to make changes to the file from within the container without disturbing the original. Follow these steps:
Editing a Linked or Embedded ObjectIf you need to make some changes to a linked or embedded object, you can use the container application to launch the server application and load the object automatically. (Remember, too, that for a linked object, you can always run the server application and work with the object directly.) How you do this depends on the application, but here are a few methods that work for most containers applications:
|