Task.TimeScaleData: unexpected method error

N

Natalie

Hello,

I'm trying to get the daily baseline costs for each task of a project using
TimeScaleData

It works for the first task, but starting from the second task on, I get an
exception.

My code in VB.NET looks like this:

################################

Dim tmpTimeScaleValues As MSProject.TimeScaleValues
Dim tmpTimeScale As MSProject.TimeScaleValue
Dim tmp as Double

For Each task In ActiveProject.Tasks


tmpTimeScaleValues = task.TimeScaleData(
CDate(task.BaselineStart),
CDate(task.BaselineEnd),
MSProject.PjTaskTimescaledData.pjTaskTimescaledBaselineCost,
MSProject.PjTimescaleUnit.pjTimescaleDays)

For Each tmpTimeScale In tmpTimeScaleValues
tmp = CType(tmpTimeScale.Value, Double)
....
Next tmpTimeScale

Next task

##########################

I get an exception while trying to access "tmpTimeScale.Value".
The exception says: unexpected method error (in German "unerwarteter
Methodenfehler").

As I already mentioned, it works fine for the first task, but starting from
the second task on, I get the described exception.


Any ideas?

Thank you
Natalie
 
J

John

Natalie said:
Hello,

I'm trying to get the daily baseline costs for each task of a project using
TimeScaleData

It works for the first task, but starting from the second task on, I get an
exception.

My code in VB.NET looks like this:

################################

Dim tmpTimeScaleValues As MSProject.TimeScaleValues
Dim tmpTimeScale As MSProject.TimeScaleValue
Dim tmp as Double

For Each task In ActiveProject.Tasks


tmpTimeScaleValues = task.TimeScaleData(
CDate(task.BaselineStart),
CDate(task.BaselineEnd),
MSProject.PjTaskTimescaledData.pjTaskTimescaledBaselineCost,
MSProject.PjTimescaleUnit.pjTimescaleDays)

For Each tmpTimeScale In tmpTimeScaleValues
tmp = CType(tmpTimeScale.Value, Double)
....
Next tmpTimeScale

Next task

##########################

I get an exception while trying to access "tmpTimeScale.Value".
The exception says: unexpected method error (in German "unerwarteter
Methodenfehler").

As I already mentioned, it works fine for the first task, but starting from
the second task on, I get the described exception.


Any ideas?

Thank you
Natalie

Natalie,
I'm not a VB.net programmer but the basic problem is that your code does
not create a collection object representing the timescaled values.
Therefore, when you try to loop through all values in the collection,
there is in fact only one. To create a collection of timescale values,
add as "set" statement as follows:
Set tmpTimeScaleValues = task.TimeScaleDate(.. . .)

Hope this helps.
John
Project MVP
 
J

Jan De Messemaeker

Hi Natalie,

I was once told that in VB.net you do not need the set instruction to defien
an object so I'm afraid John's comment is insufficient.
In which statement do you get the exception?
 
J

John

Jan De Messemaeker said:
Hi Natalie,

I was once told that in VB.net you do not need the set instruction to defien
an object so I'm afraid John's comment is insufficient.
In which statement do you get the exception?

Jan,
OK, as I said, I'm not a VB.net programmer. I was hoping it was a simple
fix.

John
 
J

Jan De Messemaeker

No sweat John, I was told the same thing gently by Rod a few years ago when
I made the same comment as yours :))
 
N

Natalie

Hi Jan,

Thanks for your feedback.

I get the exception at "tmpTimeScale.Value", that is when I try to access
"Value" of the TimeScaleValue object.

The TimeScaleValue object seems to be available, since I can access its
"Startdate" and "Enddate" properties, but I get an exception if I try to
access its "Value" property.

Regards
Natalie
 

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