3 4
Microsoft Office XP Developer includes a number of advanced add-ins for developers. Office XP Developer includes utilities for working with VBA code, creating file packages for distributing databases you develop, and coordinating development work for a development tool, among others. You access these add-ins via the Add-Ins menu of the Visual Basic Editor.
Even if you’ve installed the Office Developer Tools component of Office XP Developer, you might not see all of the add-ins on the Add-Ins menu, because they must be loaded first. You can see the available Visual Basic Editor add-ins in the Add-In Manager dialog box, and for each one, you can set its load properties. For example, if you want to have the Code Commenter And Error Handler Add-In always loaded at startup in the Visual Basic Editor, follow these steps:
If you don’t want an add-in to always be loaded because you use it only occasionally (the Packaging Wizard is an example), you can select the Loaded/Unloaded check box to load it for the current session only. Figure 15-22 shows the Add-In Manager dialog box with the Code Commenter And Error Handler and Multi-Code Import/Export add-ins loaded and set to load on startup and the Packaging Wizard loaded for the current session only.
Figure 15-22. The Add-In Manager dialog box lets you set startup and load options for various Visual Basic Editor add-ins.
caution
Troubleshooting - I can’t find the Code Librarian
The Code Librarian, one of the Office Developer Tools in Office XP Developer, was available from the Add-Ins menu in the Access 2000 Visual Basic Editor. It’s now a separate Developer Application, which you can select from the Microsoft Office XP Developer program group.
The Code Commenter And Error Handler add-in combines two separate add-ins: It inserts a comment header section and a standard error handler into procedures using a customizable template (EHT file). To use the Code Commenter And Error Handler add-in, follow these steps:
Figure 15-23. The Code Commenter And Error Handler Add-In dialog box lets you add comments and error handlers to VBA code.
Figure 15-24 shows the Comments header block of a procedure after the standard template has been applied.
Figure 15-24. This Comments header block was inserted by the Code Commenter And Error Handler add-in.
The error hander inserted by the add-in is shown in Figure 15-25.
Figure 15-25. This error handler was inserted by the Code Commenter And Error Handler add-in.
note
The error handler is in the form of a Select Case statement with only Case Else filled in. You can insert other Case statements as needed to deal with specific errors.
The Multi-Code Import/Export add-in allow you to import or export a number of objects in one pass, which can save a good deal of time. To import objects, follow these steps:
Figure 15-26 shows some modules imported in the Project Explorer pane.
Figure 15-26. Two newly imported modules are shown in the Project Explorer pane.
InsideOut
Although Access form and report modules are class modules and they appear in the Select Files To Import dialog box, you can’t import them using the Multi-Code Import dialog box. When you import a form or a report in the Access interface, its class module (if any) will also be imported.
To use the Multi-Code Export add-in, follow these steps:
Figure 15-27. You select multiple files to export in the Multi-Code Export dialog box.
note
The VBA String Editor add-in automatically inserts quotation marks, carriage return constants, and other syntactical elements into strings, which saves you time and reduces errors (such as a missing set of quotation marks). This add-in is useful for constructing strings to be displayed in message boxes or strings to be printed in the Immediate window by Debug.Print statements.
To work with this utility, follow these steps:
Figure 15-28. The VBA String Editor dialog box offers several toolbar buttons for working with string expressions.
Figure 15-29. The VBA String Editor indicates variables in a string using blue, boldface type.
FirstName LastName lived at StreetAddress on OrderDate
from Figure 15-29 becomes
FirstName & " " & LastName & " lived at " & StreetAddress & _ " on " & OrderDate
The VBA String Editor does an excellent job on simple expressions like this one, but it might not be able to process more complex expressions properly, particularly those that need nested quotes. For example, the editor translates this string:
strCriteria = [fldTaskID] = intTaskID And [fldProjectKey] _ = strProjectKey And [fldTaskConsultant] = strResource
into the following string:
strCriteria & " = [fldTaskID] = " & intTaskID _ & " And [fldProjectKey] = " & strProjectKey _ & " And [fldTaskConsultant] = " & strResource
Instead, it should have been translated into the following expression (because the string variables need to be surrounded with quotation marks):
strCriteria = "[fldTaskID] = " & intTaskID & " And _ [fldProjectKey] = '" & strProjectKey & "' And _ [fldTaskConsultant] = '" & strResource & "'"
Even though it might not parse an expression perfectly, the VBA String Editor takes a good deal of the pain out of formatting complex expressions in VBA code.
Office XP Developer includes a Packaging Wizard, which helps you prepare distributed applications. (This add-in is covered in Appendix B, "Distributing Your Access Application.") It also includes Microsoft Visual SourceSafe, which is used to implement source code control and allows multiple developers to work on an application without overwriting each other’s work. If you have Visual SourceSafe version 6.0 or later installed, you can use the VBA Source Code Control add-in to help implement source control.