Section 25.2. Embedding and Linking Objects


25.2. Embedding and Linking Objects

Embedding and linking are two tools that let you build compound documents , which contain content from two or more applications. Maybe you have a Word file that contains an Excel worksheet. You can save this document as one file and print it as one document, but you need to use both programs to edit its content. Figure 25-1 shows an example.

Figure 25-1. If you place an Excel chart inside a Word document (as shown here), the chart is stored in a floating box, and the document's text flows around it. The document looks just as it would if you had used Word's Insert Illustrations Picture command to place a picture of the chart in your document.


Embedding and linking are really two different, but related , concepts.

  • Embedding means that a copy of one document is physically stored inside the other. If you embed an Excel chart in a Word document, the Word (.docx) file contains all the Word document content and all the Excel worksheet data.

  • Linking means that one document contains a reference to another document. If you put an Excel chart inside a Word document using linking, the Word file stores the Excel workbook file's name and file location information. A linked document still stores some of the information from the original source, so that you have something to show even if the link gets disrupted (if you delete the source file, for instance). However, a linked document's real power is that you can refresh the link whenever you need toat which point, Excel copies the latest information from the source document.

Both embedding and linking generate the same results visually. Which one you use depends on how you plan to update the document. When you embed an object, you create a copy of the data inside the new document. You can edit that data separately, but it's no longer attached to the original source document. When you link a document, any changes you make to the source document automatically appear in the linked document. If you insert a chart inside a Word document, and then modify the chart in your worksheet, then the Word document also gets updated.


Note: Overall, embedding is easier to manage, but linking is your best approach if the source data changes frequently and you want to make sure the compound document always has the latest and greatest information. Linking also makes sense if you want to keep several documents synchronized with the same data (you want to do something like show an important worksheet table in four different Word reports ). Embedding usually leads to larger files because more information is placed into one file (the compound document that contains the embedded objects).

25.2.1. Exporting Charts out of Excel

The best way to understand how linking and embedding work is to try them yourself. Follow these steps to transfer an Excel chart into another Office application like Word:

  1. Open a workbook that contains a chart .

    If you don't have a chart yet, create it now using the skills you picked up in Chapter 17, or download a workbook containing an example chart from the "Missing CD" page at www.missingmanuals.com. (You can find workbooks with all sorts of charts in the folder named Chapter17, which has the downloadable content.)

  2. Select the chart, and then choose Home Clipboard Copy .

    The Windows clipboard is the key to transferring data between all Windows applications. Once you've transferred data to the clipboard, you can retrieve it in another application.

  3. Switch to the application where you want to insert the data. Open the target document (or start a new document) .

    In this case, you need to switch to the Office application (like Word or PowerPoint) where you want to place the chart. If you don't have a suitable document, just create a new one (you can use the Office button New command in Word or PowerPoint).

  4. Paste Special command. When you use this command, youll see a Paste Special dialog box (like the one shown in Figure 25-2) that lets you pick whether the object is linked or embedded, and what format it uses.

    Figure 25-2. Many Windows applications provide a Paste Special command. When you use Paste Special, you can choose to embed or link the object (depending on whether you select "Paste" or "Paste link"). You also have the option of converting the object into any of the formats listed in the As list box. In this example, you can paste the Excel chart as a Microsoft Office Excel Worksheet Object, which lets you edit the chart data later on. Or, you can paste your chart using one of a variety of different picture formats.


    Oddly enough, in an Office application, you'll get better results by not using the Paste Special command. Instead, use Ctrl+V to perform an ordinary paste. Then, choose between linking and embedding using the smart tag that appears next to the inserted object (Figure 25-3). If you take that route, there's no need to follow the rest of the numbered steps in this section.

    Figure 25-3. Instead of using the Paste Special command in Word, you can simply use Home Clipboard Paste (or the shortcut Ctrl+V). In this case, Word takes its best guess about what youre trying to do. In this example, it inserts a linked chart object. If you act fast, you can change this option by clicking the smart tag icon that appears in the picture box's bottom-right corner. When you click it, Word displays the menu of options shown here.


  5. Choose either "Paste" to insert an embedded object, or "Paste link" to insert a linked object .

    Remember, an embedded object is a copy of the source data that's inserted into your document. A linked object is simply a reference that points to the original file.

  6. Choose the format you want to use .

    When you use the Paste Special command, the target application takes a look at the object that's on the Windows clipboard. If you're pasting the chart into a Word document, Word examines the clipboard data and determines that you're copying an Excel chart. However, every chart object has the built-in smarts needed to convert itself into a picture. The Paste Special dialog box gives you the choice of pasting the actual chart object or creating a snapshot of the chart and pasting the snapshot instead. (Word also gives you another pasting option, as explained in Figure 25-3, for those folks who simply can't wean themselves from using the plain- vanilla Paste command.)


    Tip: When you paste a chart as a picture, you can't edit the chart later on. But you get a much smaller overall file size (since the picture takes up much less room than an embedded object). So, pasting a picture is a perfect choice if you don't want to change the chart later (or if you want to make sure that nobody messes with the chart).
  7. Click OK to paste the object .

    The object appears inside the target document in a floating box.

UP TO SPEED
The Clipboard's One-Object Rule

Windows imposes one restriction when you copy data. You can have only one object on the clipboard at a time. When you copy a new object, any objects you've previously copied become unavailable. It's surprisingly easy to stumble into this problem because many different programs use the clipboard to store copied information. Windows Explorer's file-copying feature and Word's text-copying tool both use the Windows clipboard and displace whatever's currently there.

Fortunately, Excel and other Office applications don't always need to suffer from this limitation, since they have the Clipboard pane, as described in Section 3.2.3. The Clipboard pane shows a list of recent objects you've copied in any Office application. Of course, the Clipboard pane can't help you if you're copying from information between Excel and another non-Office program, because the Clipboard pane is available only to Office programs.



Note: When you save a document that contains embedded objects, the file itself doesn't look any different. A Word document with an embedded Excel chart retains the standard .docx file extension. In fact, if you look at the file in Windows Explorer, you can't tell that it contains embedded Excel data in addition to its regular Word content.

To the untrained eye, there's no way to tell if your pasted chart is a homegrown image (stored as raw picture data) or an embedded object that's owned by a specific program. Either way, it looks like a floating box that you can move around your document as you see fit. You'll notice a difference only if you want to modify your chart. If you've pasted an ordinary picture, you can't change the chart directly. Your only option is to delete the picture, edit the chart in Excel, and then paste in the new one. On the other hand, if you've pasted full-fledged Excel data, you can modify that data to alter the chart (as described in the following sections).


Note: There's no reason you can't embed one object inside another, and then take that compound document and embed it as an object inside yet another application. This "Russian doll" approach probably won't accomplish anything except confusing everyone who uses the document, but it's completely possible.
UP TO SPEED
How Special Is Paste Special?

Different programs differ slightly in how they work with linking and embedding. In Office applications, the Paste Special command gives you the most flexibility, and most Windows programs provide this menu option. However, a few applications don't provide a Paste Special feature, in which case you have to rely on the less nimble Paste command.

Consider the simple Microsoft Paint drawing program, which comes with just about every version of Windows ever created. (You can run Paint by going to the Start menu, and then selecting Programs Accessories Paint.) If you go to the Paint menu, and then select Edit Paste while an Excel chart is on the clipboard, Paint inserts a picture of your chart. Paint doesnt support object linking and embedding at all.

On the other hand, if you use WordPad (from the Start menu, select Programs Accessories WordPad), and you select Edit Paste, then WordPad inserts an embedded Excel object. These examples just go to show that different programs make different choices when you use the Paste command. To control exactly what happens, look for a Paste Special command instead.


25.2.2. Editing a Linked Object

If you've inserted a linked object, you can easily change the linked content. Just open the original file in Excel, and then tweak the numbers . For example, if you pasted a linked chart object into Word, the next time you open the Word document you see the newly modified chart. The best part is that you don't need to do anything to tell Word to update its chart.

You can also use the program that has the linked object (in this example, Word), to open the linked object in the appropriate program (in this case, Excel). The exact process for doing this depends on the application that contains the linked object. In many Windows applications, you need to right-click the linked object, and then choose Linked Worksheet Object Edit Link (or just double-click the object). This action pops up a new Excel window with the corresponding workbook. However, Word is a bit smarter . As soon as you select a linked chart, it adds the familiar Chart Tools tabs to its own toolbar (Figure 25-4, circled). If you want to see or change the Excel data in the original workbook file, right-click the chart, and then choose Edit Data.

Figure 25-4. Thanks to the tight integration between Office programs, you can do some chart tweaking right inside Word.


Sometimes, when you change the worksheet data, the changes don't appear in the linked object right away. To trigger a refresh right away in a non-Office application, right-click the chart, and then look for an Update Link command. Or, in an Office application like Word, select the chart, and then choose Chart Tools Design Data Refresh Data. If you cant do either of these things (for example, you're in a non-Office application that doesn't have the Update Link command), just close the document that contains the linked object, and then open it up again to force it to get the latest data.


Tip: Linking works particularly well if you want to insert only a small part of a much larger workbook. Linking doesn't increase the size of the target document because it stores only a link to the worksheet containing the data you're using.

25.2.3. Editing an Embedded Object

Working with an embedded object is sometimes a bit trickier because the Excel object is actually stored inside the other file (for example, inside a .docx Word document). As a result, you can't just open the workbook directly in Excel. Instead, you need to open the host program (like Word), and then tell it to fire up Excel for you.

Different programs vary in how they work with embedded objects. If you've transferred an object from Excel and embedded it in another Office application using Ctrl+V (the ordinary Paste command), you'll get the same nifty integration you saw in Figure 25-4. Just select the chart and use the Chart Tools tabs to perform some basic tweaking, or right-click your chart and choose Edit Data to pop open an Excel window that shows you the original workbook in the exact state it was when you performed the copy. When you edit this workbook, it seems like you're editing a standalone workbook file. However, in reality, your data is coming from another file in another program (like a Word document or a PowerPoint presentation).

If you've embedded a chart in a non-Office program, you're in for a bit more work. Usually, you need to right-click the object and then choose a command like Worksheet Object Open to launch Excel. When the new Excel window appears, youll notice that your workbook doesn't look exactly the same as you left it (Figure 25-5). That's because when you paste an embedded chart to a non-Office program, Excel moves the chart to a separate worksheet, and displays only that worksheet in the document.

To change your data, you need to find the worksheet where the chart's data resides. This task isn't too difficult because an embedded chart object actually contains your complete workbook. You can switch from one worksheet to another using the familiar worksheet tabs. (Here, the original chart data is in Sheet1.)

Figure 25-5. To change your data, you need to find the worksheet where the chart's data resides. This task isn't too difficult because an embedded chart object actually contains your complete workbook. You can switch from one worksheet to another using the familiar worksheet tabs. (Here, the original chart data is in Sheet1.)


When you're finished making your changes, choose Office button Close and Return to close the "virtual workbook and automatically insert the new data back into your compound document.


Note: Embedded data is always stored in the document where it's embedded. In the previous example, there are two separate copies of the workbook. One is stored in a workbook file, and the other is embedded in the Word document. It's important to realize that these two documents are completely separate. If you modify one, it doesn't affect the other. In fact, you can even delete the original workbook file and still use the embedded one.
FREQUENTLY ASKED QUESTION
Super-Size Compound Files

My compound files are giganticis there anything I can do to keep the size down?

An embedded chart object contains more than just the chartit also has the original worksheet's data. You need some of the data to build the chart. To be on the safe side, Excel embeds the entire workbook in the document. Other objects, like pictures and additional charts, also come along for the ride. These accessories are among the reasons a compound document can quickly bloat to an uncomfortably large size.

Before you embed an object, it's a good idea to create a new Excel workbook that doesn't have any unnecessary data or objects. If you want to embed a chart, start by saving a new version of the workbook that contains the chart. Then, delete all the extra information in the workbook. Once you're finished paring the workbook down, you're ready to embed the chart in another application. This technique cuts down on the amount of information that the target application needs to store.


25.2.4. Importing Objects into Excel

You can use the same process described in the previous section to copy objects out of other programs and place them inside Excel. In Excel, embedded objects appear as floating boxes (like pictures and charts). You can position these floating boxes wherever you want on your worksheet.

Embedding doesn't make sense for all types of objects. Although technically you can paste a bunch of text from a Word document as a floating object in a box, it doesn't integrate all that naturally into an Excel worksheet. However, other types of objects may make more sense. One example is an image format that Excel doesn't support. You could paste this image as an embedded object by copying it from the appropriate drawing program. The trick is Excel's Home Clipboard Paste Paste Special command, which works just like it does in all other Office applications, including Word.

Figure 25-6 shows an example of an object that's been transferred from Visio, a program that helps create diagrams.

Figure 25-6. Visio is a leading diagramming tool. Thanks to linking and embedding, you can integrate Visio objects into your worksheets as easily as charts or pictures. When you select Home Paste Paste Special in Excel and theres a Visio drawing on the clipboard, Excel lets you convert the diagram to a graphic, or paste it as a linked Visio object, as shown here.




Excel 2007[c] The Missing Manual
Excel 2007[c] The Missing Manual
ISBN: 596527594
EAN: N/A
Year: 2007
Pages: 173

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net