|
View Full Version : Clearing Time-Scaled Values Problem
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
Rod Gill 07-04-2007, 01:05 AM Hi,
Is the task that causes a crash a normal, summary or milestone task?
If you delete the task and run the macro, does it work? If so, then you may
have a corruption. delete the task and re-create it.
--
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
----------------------------------------------------------------------------------------------------
"JJ" <metaldogo70@gmail.com> wrote in message
news:1183506636.410162.264040@o11g2000prd.googlegroups.com...
>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
>
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.
On Jul 3, 5:05 pm, "Rod Gill" <rod AT project-systems DOT co DOT nz>
wrote:
> Hi,
>
> Is the task that causes a crash a normal, summary or milestone task?
>
> If you delete the task and run the macro, does it work? If so, then you may
> have a corruption. delete the task and re-create it.
>
> --
>
> 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
>
> ----------------------------------------------------------------------------------------------------
>
> "JJ" <metaldog...@gmail.com> wrote in message
>
> news:1183506636.410162.264040@o11g2000prd.googlegroups.com...
>
> >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
Rod Gill 07-04-2007, 03:42 AM 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
----------------------------------------------------------------------------------------------------
"JJ" <metaldogo70@gmail.com> wrote in message
news:1183508751.121259.267400@m37g2000prh.googlegroups.com...
> 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.
>
> On Jul 3, 5:05 pm, "Rod Gill" <rod AT project-systems DOT co DOT nz>
> wrote:
>> Hi,
>>
>> Is the task that causes a crash a normal, summary or milestone task?
>>
>> If you delete the task and run the macro, does it work? If so, then you
>> may
>> have a corruption. delete the task and re-create it.
>>
>> --
>>
>> 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
>>
>> ----------------------------------------------------------------------------------------------------
>>
>> "JJ" <metaldog...@gmail.com> wrote in message
>>
>> news:1183506636.410162.264040@o11g2000prd.googlegroups.com...
>>
>> >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
>
>
|
|
|