Clearing Time-Scaled Values Problem

J

JJ

I have a subroutine that removes all cost data while trying to ensure
that no dates are affected. For lack of a better term, it is a "Cost
Strip" subroutine.

The following is a portion of code that I have that works 99% of the
time. But I have a Project file that crashes Project when this code...
when a particular line is executed.

For Each t In allt
If Not (t Is Nothing) Then
If t.ExternalTask = False Then

Set TVALW =
t.TimeScaleData(ActiveProject.ProjectStart - 780, _

ActiveProject.ProjectFinish + 780, _

pjTaskTimescaledBaselineWork, _
pjTimescaleMonths)

Set TVALC =
t.TimeScaleData(ActiveProject.ProjectStart - 780, _

ActiveProject.ProjectFinish + 780, _

pjTaskTimescaledBaselineCost, _
pjTimescaleMonths)

For x = 1 To TVALW.count
If TVALW.Item(x).Value <> "" Then
TVALW.Item(x).Clear
<=== *** ERROR OCCURS HERE ***
End If
Next x

For x = 1 To TVALC.count
If TVALC.Item(x).Value <> "" Then
TVALC.Item(x).Value = 0
End If
Next x

t.BaselineCost = 0
t.BaselineWork = 0

t.Cost1 = 0
t.Cost2 = 0
t.Cost3 = 0
t.Cost4 = 0
t.Cost5 = 0
t.Cost6 = 0
t.Cost7 = 0
t.Cost8 = 0
t.Cost9 = 0
t.Cost10 = 0
t.FixedCost = 0

End If
End If
Next t

I have indicated in the code above where the problem occurs. Can
anyone tell me what would cause this line to crash the entire
application? Is there anything that I need to check that I am not
doing?

I inherited this code from another developer so I only have a basic
understanding of what time-scaled values are in Microsoft Project. Any
help would be greatly appreciated!

Thank!
JJ
 
J

JJ

The error occurs from the very first task, which is a Summary task.

I deleted the task and re-ran the subroutine. I got the same result.

If it is a corruption, how do I find what and where the corruption
occurs?

Thanks!
JJ

It is the only task at Outline Level 1 in the entire project.
 
R

Rod Gill

Your code is selecting monthly time periods and maybe Project does not like
the first or last period being cleared. Try manually clearing the baseline
data in the Resource Usage view. You need to add Baseline work to the view
and adjust timescale to manual. Let us know what happens.

--

Rod Gill
Project MVP

Project VBA Book, for details visit:
http://www.projectvbabook.com

NEW!! Web based VBA training course delivered by me. For details visit:
http://projectservertraining.com/learning/index.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top