Platinum Edition Using Windows 98

Previous chapterNext chapterContents


- 11 -

Sharing Data Between Applications


by Bob Voss and Keith Underdahl

Understanding the Data-Sharing Capabilities of Windows 98

Windows 98 enables you to share data between different applications in a variety of ways. These range from simple cut-and-paste operations to advanced linking and embedding of various objects. Which method you use will depend not only on your specific needs at the time, but also on the applications you are using.

Compound Documents and the Windows Clipboard

The simplest level of data sharing is done using cut-and-paste or copy-and-paste. When you select a piece of data such as text or an image and use an Edit, Cut or Edit, Copy menu command, the object is placed in an area of Windows called the Clipboard. It can then be pasted into virtually any applet or application. In theory, this is like using scissors and glue to paste together a school newspaper or a Mother's Day card.

The Clipboard's strength lies in its versatility. It handles any kind of data that Windows can interpret, which can then be pasted into various types of documents. This allows the creation of compound documents, which can hold text, pictures, spreadsheet data, and more (see Figure 11.1). Of course, you need to keep in mind that although the Clipboard can hold many kinds of data, not all data can be pasted into all applications. For instance, you cannot paste an image into a Notepad document because Notepad won't support it. And while text can usually be pasted anywhere, you might lose some formatting (bold, superscript, and so on) in the pasting process.

FIG. 11.1 This compound document contains several different kinds of data.

A potential drawback, however, is that all applications might not be able to edit all types of data. For instance, suppose you have pasted a picture into a word processing document. Later you realize that you need to resize the picture, or perhaps you need to convert it from color to black and white. If the word processing program doesn't have image-editing capabilities (it probably doesn't), your only solution might be to manually remove the image and open it with another program that can edit it. And when you finished editing it, you would have to paste it back into the word processor, which might require repositioning text, moving things around, and so forth.

Understanding Object Linking and Embedding

As wonderful as the Windows Clipboard is, it still presents certain limitations. What if you want to create a document containing two types of data that change frequently? Enter Dynamic Data Exchange (DDE), a protocol developed by Microsoft many years ago to address this problem. This allows the data object to be accessible to the program it was created in (the server application), as well as to many other programs (client applications) at the same time.

For instance, suppose you are responsible for publishing a monthly training report for your company. You might track training hours for each employee using an Excel worksheet (see Figure 11.2), but you need to use this data in the monthly report that you publish with a word processor.

FIG. 11.2 This worksheet tracks data that must be input into the monthly training report.

In the published report, most of the text stays the same from month to month, and the only real changes occur in the actual training numbers. Thus, copying and pasting data from the worksheet would be inefficient, because you would have to re-paste the data every time you prepared the report. With the data sharing technology called Object Linking and Embedding (OLE), you can link the data to the other application for quick, efficient updating of the data.

An extension of the object linking concept is object embedding. Embedding allows you to edit a data object without leaving the client application. For example, suppose you want to edit an image you embedded into a word processing document. Clicking on the image enables you to use controls from Paint (or another image editor) to edit the object within the word processor.

OLE technology extends to Internet documents as well. To an ever-increasing extent, cybersurfers expect web content to be both interactive and up-to-the-minute. ActiveX controls, for instance, utilize the OLE concept to automate functions and link applications. This allows web sites to be truly interactive, as they ask for user input, launch browser plug-ins, and more. ActiveX controls are also used by the new Windows 98 Help system, which is HTML-based. This allows Windows Help to link with other applications to better illustrate its topics.


JavaScript or ActiveX?

JavaScript and VBScript (the scripting used to enable ActiveX controls) are different languages that serve the same purpose. JavaScript is similar to the programming language Java and is provided by Netscape. On the other hand, Microsoft has championed VBScript, an offshoot of its own Visual Basic.

Given this, you can easily surmise that JavaScript works better with Netscape Navigator, and VBScript works best with Internet Explorer. With the right plug-ins, however, a Netscape user can still take advantage of ActiveX controls. One such plug-in is ScriptActive from NCompass, which is available online at http://www.ncompasslabs.com.


A good example of this might be a web site that provides information about your company, including current stock market and other financial information. If you created the web page by simply copying and pasting data from the Clipboard into the HTML document, the data would not remain current for very long (unless, of course, you are willing to sit in front of the computer and manually update it 24 hours a day!). The better solution is to implement an OLE-based control that automatically updates the market data on a regular basis.

Using the Windows Clipboard

The simplest way to exchange data from one location to another, whether it is within an application or between applications, is to use the Windows 98 Clipboard. The Clipboard is an application you use to temporarily store data that you are exchanging from one location to another. You cut or copy data to the Clipboard and then paste the data from the Clipboard into a document. The data remains in the Clipboard until you cut or copy new data to the Clipboard or remove it manually, so you can paste the data into a document as many times as you like.

Cutting, Copying, and Pasting Data

The most common method for transferring data using the Clipboard is to use the menu commands that are found in most Windows applications. The Cut, Copy, and Paste commands are usually found in the Edit menu. Note the distinction between cutting and copying. When you cut data from a document, that original data is moved to the Clipboard and no longer appears in its original location. When you copy data from a document, a copy of the data is placed on the Clipboard, and the original data remains intact where it was.


NOTE: Remember, material remains on the Clipboard only until the next piece of data is placed there. If you have cut a piece of data and you plan to paste it somewhere, make sure you remember to paste it, or the data might be lost. You might be able to correct such an error with the Edit, Undo command in the application you cut it from. See "Saving the Contents of the Clipboard," later in this chapter, for more information. 

To cut or copy data from one location to another, follow these steps:

1. Select the data in the source document that you want to cut or copy to another document (or another location in the same document).

2.
Choose Edit, Cut to cut (move) the data to the Clipboard.

or

Choose Edit, Copy to copy the data to the Clipboard.

The data is placed in the Windows Clipboard. Normally the Clipboard is invisible, but you can view its contents by choosing Start, Programs, Accessories, System Tools, Clipboard Viewer. As you can see in Figure 11.3, the training data worksheet you saw in Figure 11.2 has been copied to the Clipboard and is ready to be pasted into the training report.

FIG. 11.3 An Excel worksheet has been copied to the Windows Clipboard.

3. Place the insertion point at the point in the destination document where you want to paste the data.

If you are working with a document in another application, open that application and the destination document and place the insertion point where you want the data.

4.
Choose Edit, Paste or press Ctrl+V to paste the data from the Clipboard into the destination document. Figure 11.4 shows data from an Excel worksheet pasted into a Word document.

Many applications have Cut, Copy, and Paste buttons on a toolbar that you can use instead of the menu commands. Your application might also have shortcut menus that you can display by right-clicking the selected text. The shortcut menu has the Cut, Copy, and Paste commands.

FIG. 11.4 A data table from an Excel worksheet has been pasted into a Word document.

Using Keyboard Shortcuts

The mouse pointer was truly a revolution when it was first introduced to PCs nearly two decades ago. It makes the graphic user interface possible and has made computers more accessible to millions. However, some advanced users find that they can save some time by using keyboard shortcuts instead of the mouse for certain tasks.

Fortunately, some common keyboard shortcuts allow you to forgo the mouse at certain times. For our purposes here, the most important ones for you to know are the keyboard shortcuts for Cut, Copy, and Paste, which are listed in Table 11.1.

Table 11.1  Cut, Copy, and Paste Keyboard Shortcuts

Action Shortcut Keys
Cut Ctrl+X or Shift+Delete
Copy Ctrl+C or Ctrl+Insert
Paste Ctrl+V or Shift+Insert

You can use these in place of toolbar buttons or menu commands in virtually any Windows application. In fact, these shortcuts even work in applet windows and dialog boxes that don't have any buttons or menus. You can take better advantage of these keyboard shortcuts if you also know how to select objects using the keyboard. To select an area, move your cursor to the beginning of the data and press and hold the Shift key. Then use the arrow keys on the keyboard to extend the highlight to the end of the selection and release the Shift key.


TIP: If you are using keyboard shortcuts to select text, try pressing Ctrl+Shift as you move the cursor. You'll notice that if you press the left or right arrow keys in combination with Ctrl+Shift, the cursor moves to the next word instead of just the next character. Press Ctrl+Shift+Up Arrow or Ctrl+Shift+Down Arrow to extend the highlight to the beginning or end of the current paragraph.

Using Drag and Drop to Copy Information

A second method for exchanging information is to use the mouse to drag and drop selected information, which can be text, graphics, or data, from one location to another. When you drag and drop information, the information is not stored in the Clipboard. The information is copied directly from one location to another. In this section, you learn how to drag and drop information within an application.

To use the drag-and-drop method, you must be working with an application that supports it. The applications in the Microsoft Office suite support it, for example, as does WordPad. Check the documentation or online Help for your application to find out if it supports drag and drop.

To copy information with drag and drop, follow these steps:

1. Open the application and then the document that contains the text you want to copy. Arrange the windows on your desktop so that you can see each one.


TIP: If you have multiple displays enabled on your computer, open the applications so that each one is viewable on a separate monitor. You can then drag objects from one screen to another as if they were on one giant desktop.
2. Select the text you want to copy.

3.
To copy the text, position the mouse pointer over the selected area and drag the text. The mouse pointer changes as you drag, and a plus sign (+) appears next to the pointer.

4.
Drag the text to the position in the document where you want to place it. The vertical bar indicates the position of the new text.

5.
Release the mouse button to complete the copy procedure, and the text appears in the new location.

Copying Information to a Dialog Box

Cutting, copying, and pasting information to and from dialog boxes can be tricky because there usually aren't toolbar buttons or menu commands for these procedures. Fortunately, you can easily use the keyboard shortcuts for cutting, copying, and pasting to a dialog box. For instance, suppose you are composing a web page and need to create a hyperlink. You can use your web browser to find the target web site, and then you can copy the URL from the Location box to the Clipboard. Then, when you create the hyperlink in your HTML editor, a dialog box asks you for an URL for the hyperlink (see Figure 11.5). Just press Tab to move the cursor to the correct text box and press Ctrl+V to paste in the URL.

To copy information into a dialog box, follow these steps:

1. Select the information that you want to copy into the dialog box.

2.
Choose Edit, Copy or press Ctrl+C.

3.
Open the dialog box into which you want to copy the information.

4.
Place the insertion point in the text box into which you want to copy the data.

5.
Press Ctrl+V to insert the text from the Clipboard. Figure 11.5 shows the Create Hyperlink dialog box in Microsoft FrontPage Express, in which a target URL has been pasted into the URL text box.

FIG. 11.5 Ctrl+V pastes the URL from the Clipboard into this dialog box.

When you are in a dialog box, you can't use the Edit menu or the toolbar buttons, which is why you need to make use of the keyboard shortcuts. You can reverse the previous procedure to copy data from a dialog box into a document: Select the data in the dialog box, press Ctrl+C to copy it to the Clipboard, and then use the menu, keyboard, or toolbar technique to paste the information into a document.

Capturing Screens with the Clipboard

Windows has the built-in capability to capture screens. You won't have as many editing options as you would with many of the screen-capturing applications that are available. But if your needs are simple, you can use the Clipboard to capture an image of your screen. The captured image is stored in the Clipboard in bitmap format. To capture the entire screen and paste it into a document, follow these steps:

1. Set up the screen to appear as you want it in the screen image.

2.
Press Print Screen to capture the entire screen using the screen resolution currently set for the display. The screen image is stored in the Clipboard.

To capture just the contents of the active window, press Alt+Print Screen or Shift+Print Screen, depending on your keyboard.

3.
Open the document in which you want to insert the image and place the insertion point where you want the image to appear.

4.
Choose Edit, Paste or press Ctrl+V. Windows 98 pastes the screen image into the document in bitmap format.


TIP: For best results, first paste the screen into an image editor, such as the Paint applet that accompanies Windows 98. You can use the editor to crop or touch up the image or to change some properties of the image before you paste it into your final document.

Viewing and Changing Clipboard Data

You can view the contents of the Clipboard using the Clipboard Viewer. To open the Clipboard Viewer, choose Start, Programs, Accessories, System Tools, Clipboard Viewer. The last data that you cut or copied to the Clipboard appears in the Clipboard Viewer. If the Clipboard Viewer isn't listed in your System Tools menu, start the Add/Remove Programs utility from the Control Panel and install the Clipboard Viewer using the Windows Setup tab.

Controlling File Formats

The Clipboard viewer stores information in a variety of formats to help ensure compatibility over a wide array of applications. You can easily view the available formats for a given object by performing the following steps:

1. Open the Clipboard Viewer

2.
On the menu bar, click Display. A menu appears, showing all available formats for the object currently in the Clipboard (see Figure 11.6).

3.
To change the format of the object, make a selection from this menu.

FIG. 11.6 The Display menu lists the various formats that this object can be stored in.

What formats are available will depend on the type of data that is currently in the Clipboard. The options shown in Figure 11.6 apply to most images, but text and other data types might offer many more options. The most common of these options include the following:

If you paste an object into a document using the Paste Special command, you will see a dialog box similar to that shown in Figure 11.7. In this dialog box, you can make similar choices regarding the format of the object to be pasted, but notice that the choices are now more limited (namely, Palette is no longer available). This box lists only the formats compatible with the given application--not all formats available to the Clipboard. Before clicking OK, make sure the correct file format is selected. Otherwise, you might not be able to edit the embedded object using the techniques discussed later in this chapter.

FIG. 11.7 You might be able to choose formats in the Paste Special dialog box as well.

Saving the Contents of the Clipboard

Data you copy to the Clipboard is lost when you cut or copy new data or shut down Windows. If you want to reuse that data at a later time, you can save the contents of the Clipboard as a file. To save data that's in the Clipboard Viewer, follow these steps:

1. In the Clipboard Viewer, choose File, Save As to open the Save As dialog box.

2.
Type a filename in the File Name text box (the Clipboard Viewer automatically appends the .CLP extension). By default, .CLP files are saved in the Windows folder of your hard drive.

3.
Click OK.

To open a Clipboard file that you have saved, follow these steps:

1. In the Clipboard Viewer, choose File, Open to open the Open dialog box.

2.
In the File Name list box, select the file you want to open. If necessary, select the file location from the Folders list box.

3.
Click OK.

If you currently have something stored in the Clipboard, the Clear Clipboard message appears, asking if you want to clear the contents of the Clipboard. Choose Yes to replace the current contents with the data in the .CLP file. Choose No if you don't want to clear the contents of the Clipboard.


NOTE: Microsoft provides a number of useful tools in the Windows 98 Resource Kit, which is available for download from http://www.microsoft.com/. One of the tools in the kit is called ClipTray, which allows you to quickly view and edit Clipboard contents. When you install ClipTray, it adds an icon to the system tray next to the time. Click that icon to open ClipTray. 

Exchanging Data Between Windows and DOS

You are not limited to sharing data between Windows applications. If you are still using DOS applications in the Windows environment, you can exchange information, including text and graphics, using the Clipboard. You can transfer data from Windows to DOS, from DOS to Windows, and between DOS applications. You can even transfer text from the MS-DOS command prompt to a document.

To exchange data from a DOS application to a Windows application, follow these steps:

1. Open the DOS application. The DOS application should be in a window, not full-screen.

2.
Open the Control menu of the DOS window and choose Edit, Mark, or click the Mark button on the toolbar. A blinking cursor appears in the upper-left corner of the DOS window, indicating that you are in the marking mode.

3.
Click in the location where you want to start marking, hold down the left mouse button, and drag a box around the text or graphics that you want to copy.

or

To mark the text using the keyboard, hold down the Shift key and use the arrow keys to mark the text.

4.
Choose Edit, Copy, or press Enter, or click the Copy button on the toolbar. The selection is copied to the Clipboard.

5.
Open the document in the Windows application in which you want to insert the Clipboard contents.

6.
Place the insertion point where you want to insert the Clipboard contents.

7.
Choose Edit, Paste, or press Ctrl+C, or click the Copy button on the toolbar.

Figure 11.8 shows a block of text selected in the MS-DOS Editor. In Figure 11.9, the selected text from the MS-DOS Editor document has been pasted into a Word document.

You can also copy data from a Windows application into a DOS application. However, any formatting that has been applied to the Windows data will be lost when it is pasted into the DOS application. Also, keep in mind that you will not be able to transfer some types of data (such as graphics) into MS-DOS applications.

FIG. 11.8 You can mark text in a DOS application and copy it to the Clipboard using the commands on the Control menu or the tools on the toolbar.

FIG. 11.9 This text has been copied from the MS-DOS Editor.

To copy data from a Windows application to a DOS application, follow these steps:

1. In the Windows application, open the document that contains the information you want to copy.

2.
Select the information and choose Edit, Copy, or press Ctrl+C, or click the Copy button on the toolbar. The selection is copied to the Clipboard.

3.
Open the DOS application. The DOS application should be in a window, not full-screen.

4.
Place the cursor in the location where you want to insert the contents of the Clipboard.

5.
Open the Control menu and choose Edit, Paste, or click the Paste button on the toolbar. The contents of the Clipboard is inserted into the DOS document.

Using Embedded Objects

In this section you will learn how to create compound documents that use embedded objects. Compound documents are documents you create using multiple types of data pulled in from various applications. The technology used to create compound documents is Microsoft's object linking and embedding (OLE).

The basic building blocks of a compound document are objects. Objects can be embedded into the container or client application, which contains one or more embedded objects. For example, you can embed a graphics object from a graphics application and a data table from an Excel worksheet into a Word document, which acts as the container for the objects. An application that supplies an object is referred to as a server application. The server application provides OLE services to the client application.

The major benefit of a document created using embedded objects over one created using simple copy-and-paste techniques that involve the Clipboard is that you can edit embedded objects without leaving the client application. If you use copy and paste, you have to edit the information in the source application and repeat the copy-and-paste procedure to update the client. In an OLE compound document, you simply double-click the object you want to edit, and the menus and toolbars of the object's original application temporarily replace those of the client application. Figure 11.10 shows an Excel object in a Word document. Notice that the Word menus and toolbars have been replaced with Excel's menus and toolbars so you can edit the object in place. When you finish editing the object, you click outside the object to restore the client application's menus and toolbars.

In some cases, when you double-click an object, the source application of the object opens in a separate window instead of the source's menu and toolbars appearing over those of the client. In such cases, you edit the object in its original application and then return to the compound document.

Embedded objects can be updated dynamically whenever the source data changes. One of the main benefits of using OLE applications is that you can take advantage of the strengths of several applications, each of which excels at what it does, to create a single document. For example, you can use your favorite graphics application to produce the graphics for a document, use your spreadsheet application to analyze and summarize your data, and use your word processor to create a professional-looking document. OLE enables you to pull all these pieces together into one document and then edit and update information as needed.

It is important to understand the differences between linking and embedding data. When you link information, the information is stored in the source document. The destination document contains only the code needed to locate the information in the source document. Conversely, embedded information is actually stored in the destination document, and the OLE code points to the source application instead of the source file. This enables you to access the source application's tools for editing.

FIG. 11.10 You can edit an Excel chart in Word by using OLE capabilities.

Embedding Information in Your Documents

You can embed information from one document into another using either the menu commands or drag and drop. When you use the menu commands, you have the option of linking or not linking the object with its source. When you drag and drop an object, the object is not linked to its source.


NOTE: If you have linked or embedded an object into a word processor such as Microsoft Word, you will probably need to look at the document in Page Layout View to see the object. You can change the view by clicking the View menu and choosing an option. 

To embed an object from one document to another using the menu commands, follow these steps:

1. Select the information in the source document.

2.
Choose Edit, Copy or press Ctrl+C.

3.
Open the destination application and document.

4.
Choose Edit, Paste Special to display the Paste Special dialog box.

5.
Select the object from the As list.

6.
Select either the Paste or Paste Link option.

If you select Paste, the object is embedded but is not linked to the source document. When you double-click the object, the menus and toolbars for the source application appear, allowing you to edit in place.

If you select Paste Link, the object is linked to the source document. When you double-click the object, the original document opens and the information you linked is selected. See "Linking Data" later in this chapter.

7.
Click OK, and the information is inserted into the destination document as an object, as shown in Figure 11.11.

FIG. 11.11 A Microsoft Excel table inserted as an object in a Word document. Notice the handles around the object when it is selected.

When you click the embedded object, square handles appear at the corners and ends, surrounding the object. You can drag these handles to resize the object.

You can sometimes also embed an object using drag and drop. Some OLE-compliant applications support drag and drop, enabling you to drag an object from one application and drop it in another application.

To drag and drop information from one application to another, follow these steps:

1. Open the source and destination applications and arrange their windows side by side.

2.
In the source document, select the information you want to embed.

3.
To copy the object from the source to the destination, drag the selected object and drop it at the desired location in the destination document.


NOTE: Drag and drop will not work with some applications. For instance, you will not be able to drag a table or group of cells from an Excel worksheet because the dragging operation will simply select more cells within Excel instead of copying the existing selection. If drag and drop doesn't work for you, simply use the menu or toolbar commands for copying data. 

When you drag and drop information from one application to another, you do not have the option of linking the embedded object to its source. Use the menu method just described to link an embedded object.

If the application you want to drop an object in is minimized or is hidden by other applications, you can drag the object over the application's button on the taskbar and pause for a few seconds. The application window then appears. In the application window, drop the object at the desired location.


NOTE: When you drag and drop information from one application to another, it is embedded as an object in the destination document if the data types for the two applications are different. If the data type is the same, the information is inserted in its native format. When you drag and drop a graphic to a Word document, for example, it is inserted as an object. When you drag a text selection from Word to Excel, on the other hand, it is inserted as straight text because a cell can accept text. To insert a text selection as an object, you must use the Edit, Copy and Edit, Paste Special commands. 

Inserting a File into a Document

In some cases, you might want to import an entire file from one application into another application instead of just copying and pasting part of a document. Many Windows applications have built-in file converters that enable you to convert a file of one format into the format of the application in which you are working. In many cases, the file converter preserves the formatting of the original document. For example, you can import a WordPerfect document into Word for Windows and preserve many of the formatting enhancements.

To open and convert a file from one application into another application, follow these steps:

1. Open the application into which you want to import the file.

2.
Choose File, Open and locate the folder in which the file you want to convert is stored.

You might have to choose All Files from the Files of Type (or equivalent) list box because the file you are converting probably doesn't use the same filename extension as files created by your application.

3.
From the list of files, select the file you want to convert.

4.
Click Open.

If the application has the correct conversion filter, the file is converted and opened in the application. You might need to fix some of the formatting if it was lost in the conversion process. If your application was unable to convert the file, you might not have installed the necessary converter when you installed the application. Check the documentation for your application to see what converters are included, and then run the Setup program again if necessary to install the required converter.


TIP: Rich text format (RTF) files have become the common language for exchanging files between word processors. You can preserve much of the formatting you apply to a document if you save it as an RTF file. If you don't have the correct converter for exchanging a file from one application to another, try turning the document into an RTF file and importing it into the receiving application.

Linking Data

The two techniques that you have learned so far place static copies of selected data in a new location. There is no link between the data in the source and destination locations.

A more sophisticated way to exchange data in Windows 98 is through linking. Before the arrival of the OLE standard, DDE (Dynamic Data Exchange) was the technology used to link data. Now OLE offers both linking and embedding. With OLE, you can create links from one document or file to another document or file. These links can be formed between documents that are created in the same application (such as Word) or documents that are created in different applications (such as Word and Excel). After you establish a link, you can update the linked information automatically by editing the original source information. This means you can use data in various places but update it in only one place.

You can set up a link only between two applications (or two documents) that supports OLE. The application that requests data is called the client application. The other application, called the server application, responds to the client application's request by supplying the requested data. When you change the data in the server application, Windows 98 automatically changes the data in the client application. The advantage to exchanging data by links is that data is kept up-to-date in both the client and server applications.

One example of how you can use data linking is to create a report in Microsoft Word that includes a data table linked to a worksheet in Excel. As you update the data in the Excel worksheet, the table in the Word report document is automatically updated as well, so your reports will always reflect the latest data. Using this approach, you don't have to create a new report each time your data changes. Figure 11.12 shows a data table in Excel that is linked to a document in Word (which is shown in Figure 11.13). The difference between the table in Figure 11.13 and the one shown in Figure 11.4 is that this table is linked to the data in the Excel worksheet; when you change the data in the Excel worksheet, the table in the Word document is automatically updated.

Windows 98 provides two ways to use linking: interactively and through a macro language. The simplest way to link data uses the copy and paste techniques you learned earlier in this chapter with a few important differences. Instead of the Paste command, you use either the Paste Special or Paste Link command. These commands enable you to set up the link between the source and destination documents.

The second method involves creating a macro in the application's macro language to automate data transfer or to store data in a programming variable that can then be used by another Office application. This method isn't discussed in this book. See Special Edition Using Visual Basic for Applications, published by Que, for more information on creating links using a macro language.

FIG. 11.12 Data from an Excel spreadsheet can be linked to a Word document.

FIG. 11.13 Any changes you make in the Excel worksheet will be reflected in the table in the Word document.

To set up a link between two applications, follow these steps:

1. Open the source document and select the data you want to link to a destination document (refer to Figure 11.12).

2.
Choose Edit, Copy or press Ctrl+C to copy the selected data to the Clipboard.

3.
In the destination application, open the document to which you want to link the data.

4.
Choose Edit, Paste Special, and the Paste Special dialog box appears. Figure 11.14 shows the Paste Special dialog box in Microsoft Word.

FIG. 11.14 Use the Paste Special dialog box to set up the link between the source and destination documents.

5. Select the Paste Link option. If you don't select this option, the data will be embedded into the destination document without linking.

6.
Depending on the type of data you are working with, make an appropriate selection in the As dialog box. For example, if you were pasting data from an Excel worksheet into a Word document, you would select the Microsoft Excel Worksheet (XLS) option.

7.
Click OK. The data is inserted into the destination document. (Refer to Figure 11.13, which shows the Excel data from Figure 11.12 inserted into a Word document.)

After a link is established, anytime you change data in the source document, the data is automatically updated in the destination document. Figure 11.15 shows the Excel worksheet from Figure 11.12 with some of the data changed. Figure 11.16 shows the table in the Word document from Figure 11.13 as it reflects these changes.


Why Can't I Link Some Files?

In some cases, the Paste Link option will not be available in the Paste Special dialog box. This is because the original file format of the object (before it was copied to the Clipboard) is not compatible with the client application. For instance, suppose you want to paste a JPEG image from a web site or image editor into a Microsoft Word document. When you copy it to the Clipboard, it is copied as a bitmap image, which can then be embedded in the word processor. While you may be able to paste JPEG images into Word, you will not be able to link them.

If you want to edit the embedded image, you can double-click it to open the basic image-editing controls from Paint within Word. However, if you perform more advanced editing on the original JPEG in a program such as Photoshop, you will have to re-embed or re-paste the image after you are done.


FIG. 11.15 The data from the Excel worksheet in Figure 11.12 has been changed.

FIG. 11.16 The table in the Word document is automatically updated to reflect the changes in the Excel worksheet.



CAUTION: If you change the name or path of your client or server document, you must re-establish your links. You should make a habit of changing or creating file names and directories for your documents before you create links. Otherwise, your data links will be broken, and your data will no longer be updated automatically.

Inserting a New Object into Your Document

If you want to use the features of another application in your compound documents, you can choose Insert, Object and select an application from the provided list. Many applications support this feature, including the standard Microsoft Office applications, the applications that come with Windows 98 (such as Paint and WordPad), and many other Windows 98 applications.

Some Windows applications come with small applets that can only be used from within the main application. Microsoft Office 97 comes with several smaller applications that support OLE, as you can see in Table 11.2. When you install Microsoft Office on your system, these applications are installed in a centralized location that allows many Office applications to access them easily. The WordPad application, which comes with Windows 98, can embed many types of objects, some of which are listed in the table.

Table 11.2  Office 97 Applications That Support OLE

Application Use
Microsoft Clip Gallery Inserts clip-art pictures
Microsoft Map Inserts a map showing different levels associated with data
Microsoft Equation Creates mathematical expressions
Microsoft Graph Inserts charts from data in a Word table
Microsoft Organization Chart Creates organizational charts
Microsoft Word Picture Inserts a picture and the tools associated with the Word drawing toolbar
Microsoft WordArt Creates logos and other special text effects

You can quickly and easily check your system information to find out what OLE-compatible objects are currently registered on your system. Open the System Information applet by clicking the Start button and choosing Programs, Accessories, System Tools, System Information. In the left pane of the window, click the plus sign (+) next to Software Environment, and then click the plus sign (+) next to OLE Registration. Then click on INI File to display the OLE objects available on your system (see Figure 11.17).

FIG. 11.17 The System Information applet lists OLE objects available on your system.

To insert an object from another application into a document, follow these steps:

1. In the destination document, place the insertion point where you want to insert the object.

2.
Choose Insert, Object. The Object dialog box appears (see Figure 11.18).

FIG. 11.18 The Insert Object dialog box lists applications you can use to insert objects in a document.

3. Select the Create New tab, and then select an application from the Object Type list.

4.
If you want to display the object as an icon, select the Display as Icon check box.

5.
Click OK. Depending on the applications you are working with, either a separate window for the application appears within the document, or the menu bar and toolbars change to those of the source application (as shown in Figure 11.19). In this figure, notice that although the title bar displays "Microsoft Word," the menu and toolbars are those of Excel. Likewise, the object displays the worksheet and scrollbars of Excel.

6.
Create the object using the application's menus and toolbars.

7.
When you finish creating the object, return to the document in one of two ways:

If a separate window appeared for the application, choose File, Exit, or click the window's Close (X) button.

FIG. 11.19 Some applications permit in-place editing: The menu bar and toolbars for the source application appear when you insert an object from that application.

If in-place editing was enabled, click outside the object to restore the destination application's menus and toolbars.

Editing an Embedded Object

Regardless of which method you use to embed information into your document, you can edit the embedded object with the tools of the source application. To edit the object, follow these steps:

1. Click the object. Handles appear around the object, and the status bar tells you to double-click the object.

2.
Double-click the object. Depending on the source and destination applications, either a separate window for the program appears or the current window's toolbar and menu bar change to those of the source application.

3.
Edit the object using the source application's toolbar and menus.

4.
When you finish editing the object, exit the object. If you launched a separate window for the application, choose File, Exit. If you stayed in your destination document, click outside the object.

Using OLE to Create Linked Shortcuts

Windows 98 gives you a variety of tools to make your work simpler and more efficient. In addition to the various uses we have already discussed, OLE allows you to create time-saving links in your documents. You can use links (or shortcuts) to move around within documents or to specific locations on documents of other applications. In addition, OLE allows you to create "scraps" of information that you can reuse as often as you want.

Creating Document Shortcuts

Document shortcuts enable you to quickly navigate to a particular location in a document. You can, for example, create a document shortcut on the desktop to a cell in an Excel worksheet so that you can open Excel and the target worksheet from the shortcut, and the cell will be selected. You can create a shortcut to a location or selection in any OLE-compliant application. You can keep these shortcuts on the desktop, or you can place them in a folder on the desktop if you don't want to clutter your desktop with shortcuts. Using folders to store your document shortcuts also can help you organize them.

You might use document shortcuts to save time, for example, if you are working in a document and you find you're spending a lot of time navigating from one location to another. To reduce navigation, you can create document shortcuts to key locations in the document so that you can move to a particular location using the shortcut for that location. You can then collect all the shortcuts for a document into a folder so that it becomes a computerized table of contents that streamlines navigation.

To create a document shortcut, follow these steps:

1. Make a selection in the document (select worksheet cells, text, graphics, and so on).

2.
Drag and drop the selection onto the desktop using the right mouse button.

3.
From the shortcut menu that appears when you release the mouse button, choose Create Document Shortcut Here.

When you choose a desktop shortcut, the document opens to the original selection. You can move the shortcut to a folder that you create on the desktop.


NOTE:ot all OLE-compliant applications allow you to create document shortcuts using drag and drop. In such cases, you can create a document shortcut by making a selection, choosing Edit, Copy, right-clicking the desktop, and choosing Paste Shortcut from the menu. 

Creating Document Scraps

You also can create document scraps on your desktop. Scraps are pieces of information from any OLE document that you store on your desktop or in a folder. At any time, you can drag a scrap into a document in any OLE application to insert it as an embedded object. You can use the scrap as many times as you like and in as many documents as you like. You might find scraps useful if you have certain bits of information that get used on a regular basis. For instance, you might use a scrap of your company logo in memos, faxes, reports, and various other documents.

To create a scrap, follow these steps:

1. Select the information from which you want to create a scrap.

2.
Drag the selection to the desktop or to a folder.

A scrap consisting of the selected information is created. If you choose the scrap, the information in the scrap is displayed in the application in which it was created. You can drag and drop the scrap into any OLE document to embed it as an object in the document.

Use scraps to create pseudo-post-it notes on your desktop. If you want to save a bit of information on your desktop so you won't forget it, open WordPad (open the Start menu and choose Programs, Accessories, WordPad), type the note, select the text, and drag it to the desktop. You don't have to save the WordPad file. The name of the scrap that appears on the desktop is taken from the first sentence of the scrap text. However, you can rename the scrap to give it a more useful name. To read the note, simply choose the scrap.

Another way to use scraps to increase your productivity is to store boilerplate text that you use over and over again as scraps. Suppose, for example, that you have several standard paragraphs you use repeatedly in contracts. You can create a scrap for each of these paragraphs. Then whenever you are creating a new contract and you need one of the paragraphs, you can drag a copy of the scrap into your document. You could also create a scrap that contains the same information as your .sig (signature) file in your email client. This way you can quickly attach your "virtual signature" to any OLE document. To keep your desktop from getting cluttered with scraps, organize them in folders that you create on your desktop.


TIP: You can drag a copy of a desktop scrap into an email message created using Outlook Express, which is OLE-compliant. This is a very handy way to quickly send text from a document or cells from a worksheet to a client or coworker. See Chapter 34, "Using Outlook Express," to learn how to use Outlook Express to send email.

Creating Web Links in Documents

In Chapter 30, "Web Browsing with Internet Explorer 4.0," you'll learn how to create shortcuts on your desktop to sites on the Internet. This is useful if you routinely access certain sites and want to be able to access them more quickly by double-clicking a shortcut. You also can embed these shortcuts into any OLE document so that you can access these sites from within the document. Imagine distributing a document to your colleagues loaded with shortcuts to useful sites on the Internet. All they have to do is open the document and choose the shortcuts.

To embed an Internet shortcut in a document, drag and drop the shortcut from the desktop into the document. You can then choose that shortcut to sign on to the Internet and go directly to that site.

Some applications, such as Microsoft Word 97, allow you to create web links from within the program. Look for a button on the application's toolbar called "Create Hyperlink." If the button is available, create a hyperlink using the following procedure:

1. Highlight the text or object to which you want to connect the hyperlink.

2.
Click the Create Hyperlink button on the toolbar or choose Insert, Hyperlink.

3.
The Create Hyperlink dialog box appears. Type the URL or file location into the Link to File... text box.

4.
Click OK.

The area you highlighted for the hyperlink will now appear in a different color (probably blue), as shown in Figure 11.20. Hold the mouse pointer over the link, but don't click it. Notice that a help bubble appears next to the pointer, showing the target address of the link. You can link to web sites using this method, or you can link to other file locations on your computer or network. Anyone who clicks on the link will instantly be taken to whatever location you listed when you first created the hyperlink.


NOTE: If the object you highlighted for creating your hyperlink contains text, you might have to reformat the text after the link is created. This is not a problem, but it's a good idea to keep the linked text a different color from that in the rest of your document. This will ensure that readers know it's a link. 

FIG. 11.20 Some text in this training report now contains a hyperlink to a web site.


Previous chapterNext chapterContents


© Copyright, Macmillan Computer Publishing. All rights reserved.