PRJ: GetObject Opens MPP Read-Only If Class Is Specified (152777)



The information in this article applies to:

  • Microsoft Project 98 for Windows
  • Microsoft Project for Windows 95 4.1
  • Microsoft Project for Windows 95 4.1a
  • Microsoft Project for Windows 4.0
  • Microsoft Project for the Macintosh 4.0

This article was previously published under Q152777

SYMPTOMS

When using Microsoft Project as the OLE server in an OLE Automation session, the GetObject method may unintentionally open an existing project file as read-only if the following conditions are true:

The project file name (optionally preceded with the file path) is specified in the pathname argument.

-and-

The class argument is specified ("MSProject.Project")

WORKAROUND

When specifying an existing project file while using GetObject, omit the class argument. The Class argument is redundant because the class can be deducted from the file specified, and Microsoft Project is the only application that is registered with Project files.

For example instead of the following
    Set oProjFile = GetObject("C:\TEST.MPP" , "MSProject.Project")
				
use the following code:
    Set oProjFile = GetObject("C:\TEST.MPP")
				

STATUS

Microsoft has confirmed this to be a problem in the products listed at the beginning of this article.

MORE INFORMATION

There is also inconsistent behavior when the project file is opened as Read-Only in the background in Microsoft Project and is simultaneously being referenced the same way as stated above with the GetObject method. If Microsoft Project for Windows 95, version 4.1 is being used, the file will be seen as NOT read-only when it was opened read-only manually in Microsoft Project. If Microsoft Project for Windows, version 4.0 is being used, you will see an "OLE Automation" error regardless if the project file is opened read-only or not.

For additional information, please see the following article in the Microsoft Knowledge Base:

288092 GetObject and CreateObject Behavior of Office Automation Servers

REFERENCES

"Introduction to Visual Basic for Applications, Project Edition," version 4.0, Module 3, Lesson 3: OLE Automation

For more information about the GetObject property in Microsoft Project version 4.1, click Answer Wizard on the Help menu and type:

GetObject

For more information about GetObject in Microsoft Project version 4.0, choose the Search button in Visual Basic Reference Help and type:

GetObject


Modification Type:MajorLast Reviewed:11/25/2003
Keywords:kbprb KB152777