Working day determination

S

scabHead

I am using VB to create a calendar type "report" to overcome the
much-discussed weaknesses of Project's built-in calendar view. As part of
this effort, I filter the list of tasks according to task start and task
finish and use the data to draw a calendar in Excel. Things are basically
working pretty well but there are a few headaches. I check each task for its
calendar and if none, use the project's calendar for purposes of determining
work days so I don't show a task working on a weekend when it really only
occurs on say a friday and the following monday. I use the weekday
properties to help me with this. Where I have trouble is when a task is
entered as an eday type task. In such a case the calendars are overridden. But
what vb code can I use to see if eday approach has been used on a given task?
I haven't stumbled on the property and the duration property is of no use
for this purpose as far as I can see. My only workaround right now is to
set all eday tasks to 24-hour calendars before I set them to eday tasks.
This is less than an elegant solution.
 
R

Rod Gill

When a project is saved in a database, there is a format field for the
duration that can tell you. I couldn't find anything in the object library
though. Another way around this is to use the TimeScaleData method to read
hours per day for a task. That way you can ignore calendars etc and simply
add the task to each day with work. This will account for all calendar and
elapsed duration problems.

--

Rod Gill
Project MVP

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

scabHead

Thanks Rod. I am a newbie at Project programming. After reading the help
file on the TimeScaleData method, I think it will do all that I want and will
even make my programming simpler. I had to do quite a kluge as it was. This
tip should help me dekluge it.
 
S

scabHead

I spoke too soon. After whipping out a few lines of code for test purposes,
the TimeScaleData method seems to only count hours worked versus time scale
when resources are assigned to the task. Most of my tasks do not have
resources assigned so this technique isn't going to cut it unless I made a
mistake somewhere. To use this function, I would need it to report hours
scheduled for a task even if resources are not assigned.
 
S

scabHead

Previous complaint was poorly worded. I should have said that I have a
number of tasks with essentially zero work assigned. They are used to
reference the activities of external organizations and other items. So the
timescaledata function has no work hours to parse on a day by day basis.
Only the tasks for which I have assigned resources (and therefore have work
hours computed) get any meaningful data from the timescaledata.

If project is smart enough to show that a "zero work" task that lasts 3-days
will be on Friday-Tuesday, why isn't is smart enough to let you check if
Saturday and Sunday are work days?
 
S

scabHead

I suppose what I could do is have my VB code build a temporary project file
wherein I copy task description in along with a fictitious but larger than
zero value for work. As long as I force duration and start date, I should
end up with a syncronized file. I can then run the TimeScaleData method on
that temporary project file in order to have it parse workdays properly. It
seems a bit brutal but might be the best way. I would hate the idea of
temporarily putting in fake work values on tasks in the "real" project file
lest things get corrupted.
 
S

scabHead

That was how I am doing it if you recall the original post. The problem is
that eday task entries blow things up. If edays are used, all calendars are
overridden so I can't check the calendar. I don't know of a property that
will report whether a task was entered as an e-day. The duration field
doesn't tell me the duration was entered in as an e-day. So there is my
catch-22.
 
R

Rod Gill

Try copying and pasting this into the immediate window:
?activeproject.tasks(1).Duration/application.DateDifference(activeproject.tasks(1).Start,activeproject.tasks(1).Finish,activeproject.Calendar
)

If Task 1 is 2d then the value returned is 1. If it's 2ed then 3 is
returned.
Datedifference returns the number of working minutes between two dates for a
given calendar object. Compare to the duration and that should give an
answer as to whether the duration is in ed or not.

--

Rod Gill
Project MVP

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

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