Article ID: 136880
Article Last Modified on 10/11/2006
APPLIES TO
- Microsoft Project 4.1 Standard Edition
This article was previously published under Q136880
SYMPTOMS
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.
CAUSE
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.
RESOLUTION
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:
In Microsoft Project
Sub Test()
' Add task "Task1"
Projects(1).Tasks.Add "Task1"
End Sub
Sub Test()
' Add blank task
Projects(1).Tasks.Add ""
End Sub
Using OLE Automation
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
STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
REFERENCES
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
double-click the selected text, and then double click "add method" to go to
the "Add Method" topic.
Additional query words: Run time error 7 Out of memory
Keywords: kbbug kbcode kberrmsg kbpending kbprogramming KB136880