How do you find the real duration when elapsed units are used?

R

Richard

Hi Experts,
I have the following line in my macro...
tMyTasks(lRowNum).Text10 = DurationFormat(tMyTasks(lRowNum).Duration, pjDays)
and it faithfully puts the duration in days into the Text10 field.
HOWEVER for tasks that have an elapsed duration set (eg 2ewks) it gives the
total number of normal days that fit this time, ie 2ewks X 7 days/wk *
24hours/day /8hours per shift =42 days
I would like to have Either:
the duration unit include "e" when it is an elapsed unit,
OR
just show the actual working days that the task occupies.
Any suggestions?

Alternatively, where does Project store the Duration type (unit?) that says
when a task is elapsed or normal?
 
J

John

Richard,
My suggestion, instead of trying to deal with the formatting of the
Duration value, why not calculate the duration like Project does. Use
the "DateDifference" function for working days and the "DateDiff"
functiom for elapsed days. If you always want elapsed days to appear in
Text10 when the Duration is in "edays", a few lines of code could be
used to detect whether Project is calculating "edays" or working days
for that particular task. Remember, Project calculates time spans in
minutes so you may have to apply appropriate conversion factors.

Also, remember that Project stores time related values in minutes and
what you see on the view is a formatted presentation. In other words,
even though a Duration is shown in "edays", the dimension (i.e. "edays")
is part of a formatting function Project uses internally based on
certain option settings. In yet other words, don't try to read the
"edays" text of the Duration field, you won't see it.

Finally, if you want to show the "e" for values in a spare text field,
do a string addition. For example:
[your value] & "e"
Since it is a text field to begin with, "your value" should already be a
string value.

Hope this helps.
John
 
R

Richard

Thanks again John,
A bit of clarification. I want to know if a task has been assigned an
"ELAPSED" duration or a WORK duration by the user.
I see that this could be calculated by comparing Project's Duration for a
task with both DateDiff and DateDifference to see which fits, but surely
there is a more elegant solution? Somewhere is must store the original units
that the user enters for a duration since if I enter 10d in on task and 2w in
another they both have the same length duration but Project displays the
units I entered for each. Likewise with 14ed and 2ewks.
Thanks
Richard
 
J

John

Richard,
The information may be retrievable directly from the Project database
but it is not available through the Project user interface. And although
I haven't done a full search, the information is also not directly
available through VBA.

"Elegant" is a subjective term. Sometimes elegant is the ability to
develop a clever solution for something that another person may think is
impossible.

By the way, if you want to read more about Project's database, look at
the projdb.htm file on your "C" drive.

John
 
R

Richard

John said:
Richard,
The information may be retrievable directly from the Project database
but it is not available through the Project user interface. And although
I haven't done a full search, the information is also not directly
available through VBA.

"Elegant" is a subjective term. Sometimes elegant is the ability to
develop a clever solution for something that another person may think is
impossible.

By the way, if you want to read more about Project's database, look at
the projdb.htm file on your "C" drive.

John
Thanks John, your hint about Elegance brought me back to reality. All I
needed was the work days for a task (even if the task is an elapsed duration)
so I ignored the Duration field altogether and just used DateDifference!
Works Perfectly.
Cheers
Richard
 
J

John

Richard,
So I guess then that beauty really is in the eye of the beholder.

You're welcome.
John
 

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