Microsoft KB Archive/173772
Article ID: 173772
Article Last Modified on 1/20/2007
- Microsoft Project 98 Standard Edition
This article was previously published under Q173772
If you run a Microsoft Visual Basic for Applications Sub procedure (or macro) that automates Microsoft Project 98 from a program that has a reference to the Microsoft Project for Windows 95, version 4.1 object library, you may receive the following error message:
Microsoft Project 98 is not backward compatible with the Microsoft Project 4.1 object library (Pj4en32.olb) and early binding.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements. Use either of the following methods to work around the problem.
Method 1: Reference the Microsoft Project 8.0 Object Library
- Open the module that contains the Automation code.
- On the Tools menu, click References.
- Click to clear the "Microsoft Project 4.1 Object Library" check box.
- Click to select the "Microsoft Project 8.0 Object Library" check box.
- Click OK.
Method 2: Use Late Binding
Declare your object variable as type Object, and then use the CreateObject Function or GetObject Function to set the value of the object variable.
(Using this method, you will lose the advantages of early binding, including automatic type checking, faster code, and improved readability, so Method 1 is the preferred workaround.) The following two sample functions demonstrate the difference between early and late binding.
NOTE: Microsoft Project must be running for these examples to work properly.
Sub EarlyBindingSample() Dim P as MSProject.Application Set P = CreateObject("MSProject.Application") P.SelectBeginning P.SetTaskField "Name", "test" MsgBox P.ActiveProject.Tasks(1).Name End Sub Sub LateBindingSample() Dim P as Object Set P = CreateObject("MSProject.Application") P.SelectBeginning P.SetTaskField "Name", "test" MsgBox P.ActiveProject.Tasks(1).Name End Sub
For more information about early and late binding, click the Office Assistant while in a module, type CreateObject, click Search, and then click to view "CreateObject Function."
NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Visual Basic Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:
120802 Office: How to Add/Remove a Single Office Program or Component
Microsoft has confirmed this to be a problem in Microsoft Project 98. We are researching this problem and will post new information here as it becomes available.
For more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: vba
Keywords: kbbug kbdtacode kbpending KB173772