PRJ98: Error Accessing BuiltInDocumentProperties

ID: Q185885

The information in this article applies to:

SYMPTOMS

When you attempt to use Automation to programmatically reference either the BuiltInDocumentProperties or CustomDocumentProperties collections in Microsoft Project 98, you may receive one or more of the following errors:

CAUSE

These errors occur when you attempt to use early binding. Early binding occurs when you declare a variable as an application-defined object type, for example:

   Dim prjobj as MSProject.Application

Microsoft Project 98 does not support accessing either CustomDocumentProperties or BuiltInDocumentProperties using early binding.

RESOLUTION

To work around this problem, use either of the following methods.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft Support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

Method 1: Use Late Binding

Do not use early binding to reference the Application object; use late binding instead. Late binding occurs when you declare a variable as an object rather than as an application, for example:

   Dim prjobj as Object
   Set prjobj = CreateObject("MSProject.Application ")

Method 2: Use a Second Object Variable

Use a second object variable to specifically handle only the BuiltInDocumentProperties and CustomDocumentProperties references. You can set this variable using the GetObject function, for example:

   Dim prjobj As MSProject.Application  'For early binding
   Dim prjobj2 As Object                'For late binding

   'Create the Project Object.
   Set prjobj = CreateObject("MSProject.Application")

   'Get the second object with GetObject call
   Set prjobj 2 = GetObject("c:\test.mpp")

STATUS

Microsoft has confirmed this to be a problem in the versions of Microsoft Project listed above.

MORE INFORMATION

For additional information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q163435
   TITLE     : VBA: Programming Resources for Visual Basic for Applications

Additional query words: kbDSupport kbDSD kbInterop kbAutomation
Keywords          : kbdta kbdtacode PROJVBA AutoGnrl 
Version           : WINDOWS:5.0,98
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbpending

Last Reviewed: May 19, 1999