-----Original Message-----
1) 14 days is two weeks. If you use the default project calendar there are
10 working days in two weeks.
Durations are in working days, not calendar days.
Thus if I want to increase the length of the task by two weeks I would add
ten days to the duration. Duration is stored within project in units of
minutes.
A day is 8 hours or 480 minutes. Thus to increase the duration by 10 days I
would just add 4800 to it.
Here is a simple example which adds ten days to the first task in the
project.
sub AddTenDaysToMe()
dim t as task
set t = activeproject.tasks(1)
t.duration = t.duration + 4800
end sub
Now, you need to add some code so that it doesn't do this to just the first
task. This is because often the first task is a summary task and it won't
work with summary tasks as they derive their duration from the start of the
earliest subtask to the finish of the latest subtask.
So to modify we can make it work on all tasks except summary tasks:
sub AddTenDaysToAll()
dim t as task
for each t in activeproject.tasks
if not t.summary then
t.duration = t.duration + 4800
end if
next t
end sub
This works until you hit a blank line so we add another condition
sub AddTenDaysToAllExceptBlankTasks()
dim t as task
for each t in activeproject.tasks
if not t.summary then
if not t is nothing then
t.duration = t.duration + 4800
end if
end if
next t
end sub
So that is the basic structure you use.
You need to figure out from the set of all tasks which ones you are going to
add ten days to.
Use the same code but add another internal "if... then" loop which only adds
ten days if the conditions you have set are true.
As for using datesub, well that is for dates, not durations, so I wouldn't
use it in this case.
--
Please try to keep replies in this group. I do check e- mail, but only
infrequently. For Macros and other things check
http://masamiki.com/project
-Jack Dahlgren, Project MVP
+++++++++++++++++++
.