Visual Basic Concepts

ActiveX Document Creation Basics

Creating an ActiveX document has great similarities to creating an ActiveX control. Just as with ActiveX controls, you are not necessarily in control of the host application — you are a cog in somebody else's machine. Therefore, much of your code must be defensive — allow your application to gracefully exit when necessary. And, as when developing an ActiveX control, you can expose methods, events and properties that can be used by other components.

The topics in this chapter provide the basic facts and concepts you need to create ActiveX documents. First, however, is a recap of the process of ActiveX document creation.

The Process in a Nutshell

The process of creating an ActiveX document is like creating any other project in Visual Basic:

  1. Begin by starting a new project and selecting either ActiveX Document EXE or ActiveX Document DLL. By default, these template projects contain a single UserDocument. Each UserDocument is the core object for an ActiveX document.

  2. Add controls to the UserDocument, and add code for the controls.

  3. Add a Help menu to the UserDocument.

  4. Add other forms, code modules, or more UserDocument objects to the project.

  5. Test and debug the ActiveX document by running the project and viewing the document in the target container (the container application you will eventually use to view the document — for example, Internet Explorer).

  6. Compile the project as either an in-process component, or an out-of-process component. A .vbd file (required when you use a browser such as Internet Explorer to view an ActiveX document) is also created.

  7. Deploy the ActiveX document(s).

The .exe or .dll file contains the actual compiled code. Initially, the .vbd file contains the class ID of the .exe or the .dll file. If you elect to allow users to save data (using the PropertyBag), the data will also be stored in the .vbd file. Users can view your ActiveX document by opening the .vbd file in a host application.

For More Information   Deployment of ActiveX documents is covered in "Building Internet Applications." For more information about the difference between the in-process and out-of-process components, see "In-Process and Out-of-Process ActiveX Documents." Details about the .vbd file are covered in "Parts of an ActiveX Document."