University of Virginia Department of
    Computer Science
OLE, which stands for Object Linking and Embedding, is the future of Microsoft programming. If you want to be a programmer of applications for Microsoft Windows, you need to be familiar with OLE.

Capabilities

Using OLE

The most common use of OLE is to embed an object created with a Windows application into an object created with another Windows application. An example of this type of embedding is embedding a Microsoft Excel spreadsheet into a Microsoft Word document.

Let's say that you have created a spreadsheet in Excel and saved the file as embed.xls. In your Microsoft Word document in which you would like to embed embed.xls, select Insert->Object from the Word menubar. The Object dialog will appear. Select the Create from File tab and locate your Excel spreadsheet file, embed.xls. Selecting embed.xls and pressing OK will embed the spreadsheet into your Word document, formatted to fit your Word page. By double-clicking on the newly inserted spreadsheet, the Microsoft Word menubar and toolbars change to the corresponding Microsoft Excel menubar and toolbars. Now you can use Excel to modify your spreadsheet while you're still in your Word document!

Programming OLE

OLE Controls (OCX's)

OLE programming is not for the faint-hearted. Although tools exist to make OLE programming as straightforward as possible, there is still a big learning curve to ascend before becoming a proficient OLE programmer.

The easiest place to start programming OLE applications in Visual C++ is to use the Microsoft Developer's Studio and the Microsoft Foundation Class Library. The following steps will allow you to create a very basic OLE control (OCX) using the Developer's Studio.

  1. Start the Microsoft Developer's Studio and select File->New->Project Workspace
  2. From the Type list, select OLE ControlWizard and give the project a name, e.g., SampleOLE.
  3. The Developer's Studio will create the structure of the OLE code for you and even give a preliminary implementation of the OLE control which draws an ellipse. Build the newly created project by selecting Build->Build SampleOLE.ocx from the Microsoft Developer's Studio menubar. The build process will compile and link the code into an OLE control file, SampleOLE.ocx, and will add this object to the Windows system registry. You can think of the registry as a common place that Windows uses to store properties of Windows applications.
  4. In order to use the newly created OLE control, start a Windows application, e.g., Word, and select Insert->Object from the menubar.
  5. From the Object Type list, select our newly created object, SampleOLE Control, and select OK.
  6. You've just successfully created and embedded an OLE control! You can resize and move the OLE object, or cut and paste the object, just like any other Windows object.

Advanced OLE Programming

For advanced OLE programming which involves OLE Automation or Data Access Objects (DAO), consult the OLE references listed below.

References

Books

On-line


HelpNet
HelpNet was created by the 1997 incoming graduate class. It is only occasionally updated.