PRJ41: "Out Of Memory" Adding Task or Resource in Macro

Last reviewed: September 26, 1997
Article ID: Q136880
The information in this article applies to:
  • Microsoft Project for Windows 95, version 4.1

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

-or-

   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 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.

MORE INFORMATION

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

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

   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
Issue type : kberrmsg


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 26, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.