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

Last reviewed: November 24, 1997
Article ID: Q145852
The information in this article applies to:
  • Microsoft Project 98 for Windows
  • Microsoft Project for Windows 95, versions 4.1, 4.1a

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 4.10
Keywords : kbcode kbinterop kbprg kberrmsg kbinterop kbprg kbusage
Version : 4.10 4.10a 98
Platform : WINDOWS
Issue type : kberrmsg


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 24, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.