Microsoft Office Tutorials and References
In Depth Information
Figure 6-2. The References dialog box
Generally, a project that is associated with a workbook is interested only in procedures that lie in
that project. In fact, generally it would be bad programming practice to require a procedure in one
project to call a procedure in another project. Nonetheless, there may be occasions when this is
required. To add a reference to the calling project, we use the References dialog box (under the
Tools menu), shown in Figure 6-2 .
Figure 6-2. The References dialog box
6.6.1 Fully Qualified Procedure Names
When we call a public procedure that lies in another module, there is a potential problem with
ambiguity, for there may be more than one public procedure with the same name in another
module. VBA will execute the first one it finds, and this may not be the one we had in mind!
The solution is to use a qualified procedure name , which has the form:
ModuleName.ProcedureName
For instance, if a public procedure named AddOne lies in a module named Utilities, then we can
call this procedure using the syntax:
Utilities.AddOne
If necessary, we can also specify the project name, using the syntax (don't forget to set the
reference first):
ProjectName.ModuleName.ProcedureName
It is important to note that ProjectName is the code name of the project, not the filename. (The
default code name is VBAProject.)
 
Search JabSto ::




Custom Search