Sams Teach Yourself Visual Basic 6 in 24 Hours

Sams Teach Yourself Visual Basic 6 in 24 Hours

By Greg Perry

ActiveX Documents

An ActiveX container is an application, such as Internet Explorer, that can display and activate ActiveX documents.

ActiveX documents are difficult objects to create from scratch. An ActiveX document must be contained within an ActiveX container application such as Internet Explorer. If you have Internet Explorer, try this: Start Internet Explorer but don't log on to the Internet as you might normally do. Open a Word document. If you've never tried this, you might be surprised at the results. Internet Explorer can display the Word document, formatted completely, and you can edit the document as if it were shown inside Word. Figure 21.6 shows such a document embedded inside Internet Explorer.

21fig06.gif

Figure 21.6 Internet Explorer is an ActiveX container program.

You have access to Word's menus inside the ActiveX container. You can also right-click over the text to see Word's pop-up menu. Misspelled, foreign, and abbreviated words are underlined as possible misspellings, and you can highlight and format text by pressing Word's typical formatting keystrokes (such as Ctrl+B to boldface text).

When an ActiveX container activates an ActiveX document, all the document's usual controls and features become available.

A Word document is an ActiveX document. An ActiveX container such as Internet Explorer can display and let you work within the ActiveX document. ActiveX documents are going to become more important as the Internet becomes more important. The more you work within a Web browser, the more likely it will be that you'll want to view data from another source, such as a Word document. When you're working with an ActiveX document, you don't have to start Word to read the document.

Visual Basic's Professional and Enterprise Editions include a wizard that converts your forms to ActiveX documents. Although the wizard cannot convert complete applications to ActiveX documents, you can convert forms with all their features.

To run the wizard, called the VB ActiveX Document Migration Wizard, you must add the wizard to your Add-Ins menu by following these steps:

  1. Select Add-Ins | Add-In Manager to open the Add-In Manager dialog box (see Figure 21.7).
    21fig07.gif

    Figure 21.7 Adding the wizard to the Add-In Manager.

  2. Select the entry labeled VB 6 ActiveX Doc Migration Wizard, check the Loaded/Unloaded check box, and close the dialog box. The wizard now appears on your Add-Ins menu when you display the menu.
  3. Open the application that contains the form you want to convert to an ActiveX document.
  4. Select Add-Ins | ActiveX Document Migration Wizard to start the wizard.
  5. After you click Next at the introductory dialog box, select the form you want to convert to an ActiveX document.
  6. Generally, you'll select all the defaults, so click Finish to complete the migration.
  7. Close the ending dialog boxes. Run the application to create the ActiveX document file.

Do you remember the animated form with the happy face moving up the form from Hour 18, "The Graphic Image Controls" ? If so, you'll enjoy seeing it again, only this time as the ActiveX document in Figure 21.8.

21fig08.gif

Figure 21.8 You can convert any form to an ActiveX document!

Share ThisShare This

Informit Network