PRJ: TimeScaledData Method Example Run Time Error 91

Last reviewed: November 24, 1997
Article ID: Q113397
The information in this article applies to:
  • Microsoft Project for Windows, version 4.0
  • Microsoft Project for the Macintosh, version 4.0

SYMPTOMS

The sample code for the TimeScaledData method in Visual Basic for Applications Help may produce a "Run Time Error 91" error message when you use it with projects that contain blank rows.

Under normal circumstances, this macro should run correctly and create a .CSV file.

CAUSE

The sample code for this macro does not take blank rows into account; therefore, the Run Time error is produced when the macro encounters a blank task row.

RESOLUTION

To work around this problem, add additional commands to the macro code that will trap the error situation. To trap the error, add "If Not (t is Nothing) then . . . end if" around the For Next loop in the macro. When you add this code, the error will be trapped and the example will run on files with blank task rows. The resulting code example looks like this:

Sub AssignmentsOverTime()
   Dim  t, r, temp

   Open "USAGE.CSV" For Output As #1

   For Each t In ActiveProject.Tasks
      If Not (t is Nothing) Then        'NEW LINE
         Print #1, t.Name
         For Each r In t.Resources
            temp = TimescaledData(t.ID, r.ID, ActiveProject.ProjectStart, _
                    ActiveProject.ProjectFinish, pjWork, pjTimescaleWeeks)
            Print #1, r.name & ListSeparator & temp
         Next r
      End If                            'NEW LINE
   Next t

   Close #1
End Sub

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create three tasks, and assign resource Joe to each task.

  2. From the Help menu, choose Contents. In Help, choose the Visual Basic Reference.

  3. Choose Methods, and then choose TimeScaledData, and click the Example for this method.

  4. Click the Copy button, select the example, and then choose Copy.

  5. From the Tools menu, choose Macros, and choose the New button. Paste the example into the new Visual Basic module.

  6. From the Run menu, choose Start, and select the macro and choose Run.

    NOTE: The macro will execute with no errors

  7. Insert a row between task 1 and 2.

  8. Run the Macro again.

You will receive the "RunTime Error 91" error message when macro encounters blank row.


Additional query words: 4.00
Keywords : kbcode kbprg kbcode kbprg
Version : 4.00 | 4.00
Platform : MACINTOSH 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: November 24, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.