PRJ: TimeScaledData Method Example Run Time Error 91
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
- Create three tasks, and assign resource Joe to each task.
- From the Help menu, choose Contents. In Help, choose the Visual Basic
Reference.
- Choose Methods, and then choose TimeScaledData, and click the Example
for this method.
- Click the Copy button, select the example, and then choose Copy.
- From the Tools menu, choose Macros, and choose the New button. Paste the
example into the new Visual Basic module.
- From the Run menu, choose Start, and select the macro and choose Run.
NOTE: The macro will execute with no errors
- Insert a row between task 1 and 2.
- Run the Macro again.
You will receive the "RunTime Error 91" error message when macro encounters
blank row.
Additional query words:
Keywords : kbcode kbprg
Version : MACINTOSH:4.0; WINDOWS:4.0
Platform : MACINTOSH WINDOWS
Issue type :