ID: Q136880
The information in this article applies to:
In Microsoft Project, when you use the Add method in a macro to add a task or resource to your project, you may receive the following error messages
Out of memory or system resources
followed by:
Run-time error '7':
Out of memory.
Additionally, when you run a Visual Basic macro in another program and you
use OLE Automation to add a task or resource to a project in Microsoft
Project, you may receive the error messages described above.
This problem occurs if you use the Add method of the Tasks collection, or the Resource collection, without specifying a name argument.
For example, if you run the following macro in Microsoft Project, you receive these error messages:
Sub Test()
Projects(1).Tasks.Add
End Sub
Although the Help topic for the Add method indicates that this argument is
required, it also states that by default, the name argument is Empty.
In Microsoft Project version 4.0, you can add a task or resource using the Add method without specifying a name argument. In this case, a task or resource is added without a task name or resource name.
To avoid receiving an "out of memory" error message when you add a task to a project using a macro, include a value for the name argument, even if it is empty as in the following examples:
Sub Test()
' Add task "Task1"
Projects(1).Tasks.Add "Task1"
End Sub
-or-
Sub Test()
' Add blank task
Projects(1).Tasks.Add ""
End Sub
Sub Test()
Dim x As Object, y As Object
Set x = GetObject("", "MSProject.Application")
x.FileNew
Set y = x.Projects(1).Tasks.Add ""
End Sub
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
Note that when you run a Visual Basic macro in another program and you access Microsoft Project as an OLE Automation object, if you receive the "Run-time error '7':" error message as described above, the error message may contain question mark characters such as "?4????" instead of the "out of memory" text.
For additional information, please see the following article(s) in the Microsoft Knowledge Base:
ARTICLE-ID: Q136881
TITLE : OLE Automation Run-Time Error Message Contains Question
Marks
For more information about using the Add method to add a task or resource in Microsoft Project, click the Index tab in Microsoft Project Help, type the following text
add
double-click the selected text, and then double click "add method" to go to
the "Add Method" topic.
Additional query words: 4.10
Keywords : kbcode kbprg
Version : 4.1
Platform : WINDOWS
Last Reviewed: September 27, 1997