function question

B

btidderholson

could i use the ProjDateSub function to add 14d to the
duration of any tasks that needs to be rescheduled to the
status date and that have a posted % complete?

If not, what function can i use?
 
J

Jack D.

btidderholson said:
could i use the ProjDateSub function to add 14d to the
duration of any tasks that needs to be rescheduled to the
status date and that have a posted % complete?

If not, what function can i use?

I think I'd just add 10 days of duration instead.
Like this:

task.duration = task.duration + 4800

You need to determine what sort of criteria you are using to select the
tasks, but this is simple to do once you have decided what you want.



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


+++++++++++++++++++
 
B

btidderholson

Why 10 days? Are you saying add 10 days by way of the
ProjDateSub function? Please tell me how I would write
this function...thanks
 
J

Jack D.

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.


Why 10 days? Are you saying add 10 days by way of the
ProjDateSub function? Please tell me how I would write
this function...thanks



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


+++++++++++++++++++
 
B

btidderholson

You are a gem! thank you!
-----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


+++++++++++++++++++


.
 

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