The ActiveX Document Migration Wizard
One of the most interesting ways to port your applications to the Internet is to let
Visual Basic do it for you! When you add the ActiveX Document Migration Wizard to the
Add-In Manager menu option, you add a powerful tool that will turn virtually any
Visual Basic application into an Internet-ready application. You can place your converted
ActiveX document applications on a Web server, and users can interact with your
applications through a Web browser, just as they can interact with Web pages that contain
HTML, VBScript, and Java code.
To see how easy it is to convert an application into an Internet-ready application,
follow these steps to use the ActiveX Document Migration Wizard:
- Select Add-Ins|Add-In Manager and double-click the entry VB 6 ActiveX Doc Migration
Wizard to add the wizard to your list of add-ins.
- Click OK to close the Add-In Manager dialog box.
- Open the sample Calc.vbp project that comes with Visual Basic. The project is located in
Visual Basic's Samples\Calc folder.
- Press F5 to run the application. As Figure 19.6 shows, the application simulates a
pocket calculator on your screen.
Figure 19.6
The Calc application mimics the features of a pocket calculator.
- Stop the running application.
- Select Add-Ins|ActiveX Document Migration Wizard to start the Migration Wizard.
- Click the Next button to bypass the introductory window.
- The second window appears, as shown in Figure 19.7, which lists all the current
projects' forms in a checked list. Of course, the simple Calc.vbp project contains only a
single form, so that's the only form you'll see listed here. Click the Calculator entry to
select it.

If several forms resided in your project, you could elect to send only some of the
forms to Web-compatible ActiveX documents. Each form will become its own ActiveX document.

Figure 19.7
Select the application's form that will ultimately appear on the Web page in an
ActiveX document.
- The Options window, shown in Figure 19.8, determines how the wizard handles the elements
that it cannot convert. Some kinds of advanced communications code cannot work inside an
ActiveX document, although most Visual Basic code will run smoothly. If you check the
first option, Visual Basic will place remarks before all code that the wizard cannot
convert. Although the resulting application may not be complete, you can search for the
remarks and fix or remove the code if it's vital to the application. No invalid code
exists in the Calc.vbp application, so you'll not have to choose this option.
In
addition, you may want to remove the forms that you convert from the project, because
those forms will reside in an ActiveX document after the wizard completes. Leave the
ActiveX EXE option checked so that the wizard creates an executable module as opposed to a
DLL.

A DLL, or dynamic link library, is a compiled routine that more than one
compiled application can share.

Figure 19.8
Set the options for the ActiveX document that will appear.
For this example, leave the Options dialog box with its default settings and click Next
to continue the wizard.
- Leave the default settings alone and click Finish at the next and Finished window to
start the migration of the Calc.vbp application to an ActiveX document. Once the migration
completes, a final dialog box appears.
- Click OK to close the final dialog box.

After each migration, a Summary Report window appears, such as the one shown in Figure
19.9. The Summary Report window is important, because the instructions within the window
let you know what you're to do next to test the migration. After you read through this
report, you can click the Save button to save the text and close the window. For this
example, you can close the window without saving the report.

Figure 19.9
The Summary Report window describes your next and final actions necessary to
complete the migration.
Now that you've completed the migration, you must run the application once more inside
the Visual Basic environment to prepare an executable ActiveX document object. In a way,
Visual Basic compiles the application, but unlike the typical program compilation, running
the migrated application creates an ActiveX document with the filename extension .VBD (for
Visual Basic Document). (You will still have to compile the ActiveX document into
its EXE format if you want to use the ActiveX document without the Visual Basic
environment running.)
As soon as you run the application, Visual Basic displays the Project Properties dialog
box shown in Figure 19.10. The Project Properties dialog box determines how the ActiveX
document will behave when you run the program. Look at the Project window and you'll see
two components[md]the usual Calc form and a second object named docCalculator. The
docCalculator object is the ActiveX document component you created when you pressed F5 to
run the application.
Figure 19.10
Specifying the ActiveX document's project properties.
When you click OK, Visual Basic will start the ActiveX document inside your Internet
Browser. Figure 19.11 shows the result. Notice what has happened:
- The Internet browser, itself, is executing your Visual Basic application.
- You wrote no messy HTML code to produce the Web page.
- The Calculator application is successfully migrated to a Web application.
- If you close the project, you can, at any time, restart the Internet browser, select
File|Open, locate the docCalculator.vdb file, and execute the compiled ActiveX
document-based application from inside the browser without starting Visual Basic.
- If you place the application on your Web server (assuming you have access to a Web
server from where you can offer Web pages to those on the Internet), any Internet user in
the world who owns a Web browser that is ActiveX compatible will be able to run your
application. The application will execute on the user's machine after downloading along
with the Web page. (This simulates the action of a Java applet as well.)
Figure 19.11
Internet Explorer is the platform from which the Calculator application now runs.
After you close your Internet browser, you can select Run|End to stop Visual Basic's
execution.

Any container that can hold an ActiveX control can hold an ActiveX document. That's
important to understand, because you can see how universal an ActiveX document can become.
In other words, if you use an application, such as a drawing application or another
programming language, that lets you embed ActiveX controls inside that application, you'll
be able to add your ActiveX documents to those applications as well. An ActiveX document
is just a fancy term for an ActiveX control that you migrated from a Visual Basic
application. Today's second exercise shows you how to use this drop-in feature if you have
Microsoft Office Professional installed on your computer.
