Microsoft KB Archive/145852

= PRJ: "User-Defined Type Not Defined" Error in Macro =

Article ID: 145852

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Project 98 Standard Edition
 * Microsoft Project 4.1 Standard Edition
 * Microsoft Project 4.1a

-



This article was previously published under Q145852



SYMPTOMS
When you try to declare a variable of the type "Database" that is available with the data access object (DAO) library, you may receive the following error message:

User-defined type not defined



CAUSE
Microsoft Project can make use of the DAO Object Library that Microsoft Excel and Microsoft Access install. The DAO Object Library defines a variable of the type "Database." The error is generated because there is a hidden module in Microsoft Project called "Database." This module name conflicts with the built-in object type defined by DAO.



RESOLUTION
This error does not occur if you declare your variable type as "Variant" instead of "Database." For example, instead of using the following declaration: Dim oData As Database Use the following: Dim oData as Variant This error also does not occur if the macro that is being created is stored in a project file (.mpp). To copy a macro from the default storage location of the Global.mpt to a specific project file, use the Organizer within Microsoft Project as follows:
 * 1) Open the project file that you want the macro to reside in.
 * 2) On the View menu, click More Views.
 * 3) Click the Organizer button.
 * 4) Select the Modules tab.
 * 5) Copy the Module that the macro resides in from the Global.mpt side of the Organizer to the project file side of the Organizer.

The macro will no longer cause the error.

Additional query words: 4.00

Keywords: kbcode kbinterop kbprogramming KB145852

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.