View Full Version : Task.TimeScaleData: unexpected method error


Natalie
06-27-2007, 03:38 PM
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

John
06-27-2007, 04:10 PM
In article <29C49C19-B4FD-4660-AF0B-C1B4F8F5EEAB@microsoft.com>,
Natalie <Natalie@discussions.microsoft.com> wrote:

> 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

Jan De Messemaeker
06-27-2007, 06:46 PM
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 De Messemaeker
Microsoft Project MVP
http://users.online.be/prom-ade
"Natalie" <Natalie@discussions.microsoft.com> wrote in message
news:29C49C19-B4FD-4660-AF0B-C1B4F8F5EEAB@microsoft.com...
> 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

John
06-27-2007, 07:18 PM
In article <OGXbdMOuHHA.1204@TK2MSFTNGP03.phx.gbl>,
"Jan De Messemaeker" <jandemes at prom hyphen ade dot be> wrote:

> 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 De Messemaeker
> Microsoft Project MVP

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

John
> > 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

Jan De Messemaeker
06-27-2007, 08:14 PM
No sweat John, I was told the same thing gently by Rod a few years ago when
I made the same comment as yours :-))

--
Jan De Messemaeker
Microsoft Project MVP
http://users.online.be/prom-ade
"John" <mjensen@theriver.com> wrote in message
news:mjensen-E5A600.11183727062007@msnews.microsoft.com...
> In article <OGXbdMOuHHA.1204@TK2MSFTNGP03.phx.gbl>,
> "Jan De Messemaeker" <jandemes at prom hyphen ade dot be> wrote:
>
>> 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 De Messemaeker
>> Microsoft Project MVP
>
> Jan,
> OK, as I said, I'm not a VB.net programmer. I was hoping it was a simple
> fix.
>
> John
>> > 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
06-28-2007, 11:08 AM
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



"Jan De Messemaeker" wrote:

> 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 De Messemaeker
> Microsoft Project MVP
> http://users.online.be/prom-ade
> "Natalie" <Natalie@discussions.microsoft.com> wrote in message
> news:29C49C19-B4FD-4660-AF0B-C1B4F8F5EEAB@microsoft.com...
> > 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
>
>
>

Jan De Messemaeker
06-28-2007, 04:15 PM
Hi,

I can't find a function Ctype. Where does it come from?
Gruesse,

--
Jan De Messemaeker
Microsoft Project MVP
http://users.online.be/prom-ade
"Natalie" <Natalie@discussions.microsoft.com> wrote in message
news:3EEEC21F-AA75-4955-8BF3-00F9FC6713B3@microsoft.com...
> 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
>
>
>
> "Jan De Messemaeker" wrote:
>
>> 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 De Messemaeker
>> Microsoft Project MVP
>> http://users.online.be/prom-ade
>> "Natalie" <Natalie@discussions.microsoft.com> wrote in message
>> news:29C49C19-B4FD-4660-AF0B-C1B4F8F5EEAB@microsoft.com...
>> > 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
06-29-2007, 10:36 AM
Hello Jan,

CType is a Visual Basic type conversion function:

http://msdn2.microsoft.com/en-us/library/4x2877xb(VS.80).aspx

Best regards
Natalie

"Jan De Messemaeker" wrote:

> Hi,
>
> I can't find a function Ctype. Where does it come from?
> Gruesse,
>
> --
> Jan De Messemaeker
> Microsoft Project MVP
> http://users.online.be/prom-ade
> "Natalie" <Natalie@discussions.microsoft.com> wrote in message
> news:3EEEC21F-AA75-4955-8BF3-00F9FC6713B3@microsoft.com...
> > 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
> >
> >
> >
> > "Jan De Messemaeker" wrote:
> >
> >> 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 De Messemaeker
> >> Microsoft Project MVP
> >> http://users.online.be/prom-ade
> >> "Natalie" <Natalie@discussions.microsoft.com> wrote in message
> >> news:29C49C19-B4FD-4660-AF0B-C1B4F8F5EEAB@microsoft.com...
> >> > 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
> >>
> >>
> >>
>
>
>