Adding ActiveX Controls and Code Components

When you start a project and add a UserForm module, a common Toolbox appears. It contains a standard collection of ActiveX controls called intrinsic controls. Chapter 3 covers intrinsic controls in more detail. If you want to insert an ActiveX control that is not in the Toolbox, choose Tools > Additional Controls or right-click in the Toolbox window and choose Additional Controls. The Additional Controls dialog box shown in Figure 1-19 appears.

Figure 1-19. The Additional Controls dialog box

This dialog box lists all the ActiveX controls that are properly registered on your machine. However, if you want to use a particular ActiveX control, check its End User License Agreement (EULA) to determine whether you have a license to use it in a VBA host application.

Many ActiveX controls installed with Microsoft Visual Basic, including TreeView, ListView, File, Directory, and Drive, are not licensed for use in a VBA host application. However, Chapter 19 explains some easy ways you can use the Windows application programming interface (API) to get around this dilemma.

You can add more than ActiveX controls—code components are perhaps even more common. This is the means by which your application can gain access to other ActiveX automation applications such as Microsoft Excel, Access, and Word. ActiveX automation is your key to building powerful applications that take advantage of objects exposed by other applications.

To use the objects, methods, properties, and events that other applications expose, first add a reference to that application. Choose Tools > References to open the References dialog box, shown in Figure 1-20.

Check the reference you want to add. The dialog box contains an alphabetical list of the references your application doesn't use. Later, when you write your own objects using Class modules, this is where you'll add them to your project.

References - ACADProject

Available References:

0 Visual Basic For Applications

0 AutoCAD 2006 Type Library

□ IA5 Helper COM Component 1,0 Type Library

□ IAS RADIUS Protocol 1.0 Type Library

□ 2dTranslator 1.0 Type Library

□ AcadMTrans 1.0 Type Library

□ Ac AuthEntities 16ENU. tlb 1,0 Type Library

□ AcDrConnnnon 1,0 Type Library

□ AcDwgFilterlmp 1.0 Type Library

□ AcEPIotCornrnon 1.0 Type Library

□ AcEPlotCore 1.0 Type Library

□ AcEPIotRenderer 1.0 Type Library I-! AcEPlotViewer 1,0 Tvoe Librarv



Priority il


OLE Automation -Location: Language:

C: \WINDOWS\system32\stdole2 .tlb Standard

Figure 1-20. The References dialog box

To improve performance, deselect any references your application doesn't use. Each reference must be resolved before your project loads. Depending on your project's size, this could greatly decrease how long your user waits for the application to load and run.

■ Note If your application uses an object of another application, you can't remove the reference to it without first removing the object.

0 0

Post a comment