Microsoft KB Archive/152777

= PRJ: GetObject Opens MPP Read-Only If Class Is Specified =

Article ID: 152777

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Project 98 Standard Edition
 * Microsoft Project 4.1 Standard Edition
 * Microsoft Project 4.1a
 * Microsoft Project 4.0 Standard Edition
 * Microsoft Project 4.0 for Macintosh

-



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

