SH:
IMO, what you're trying to calculate is a custom slack value. .If you want
this to work "hot" and your project is modeled so that your Launch task is
the project end-date, you can simply expose and read the total slack value
for each task. If the Launch task happens before the project end data, but
is fixed relative to the end date, it would be pretty easy to subtract that
value from Total Slack to arrive at days to the launch task. Keep in mind
that Project's slack calculations are based on task end date, to successor
start or task end date to project end date and displayed in working days.
Nonetheless, it seems to me you can get your custom slack value from
manipulating these values and converting to E-Days.
scabHead said:
I certainly "could" use the macro to fill the field in question with the
answer. It isn't as elegant an approach as having a function that is
always
"hot" though. But if that is the way it has to be done, then that is the
way
it has to be done.
Thanks
John said:
Well I created a module and put in a function but calls from the custom
field
do nothing. I get an error because it doesn't recognize the function
name.
I was hoping to have the formula for the custom field be something like
intLaunchMinusDays([start]) because the function itself can find the
specific
task. but i haven't been able to make any function calls from a custom
field. what is the trick? None of my Project documentation covers
VBA. In
Excel once you make a custom function in a module Excel treats it like
it was
a built-in function. I am not getting the similar capability in
Project thus
far.
scabhead,
First of all, Project is not Excel so don't expect it to act like Excel.
What is the trick for making a call to a custom function from a
customized field? As far as I know, Project's customized fields can only
call built-in functions.
If you developed a module, why do you need a custom field? The VBA macro
code is contained within the module and that macro can be initiated via
Tools/Macro/Macros, a custom toolbar button, a custom menu item, or can
run automatically as an event macro.
John
Project MVP
:
I searched the message boards and didn't find an existing answer to
my
question so.....
Is it possible to use reference a VBA function in the formula for a
custom
field? I wrote the following function but get errors when trying
to
reference it in setting up a formula for a custom number field. Is
there
some magic step required to render VBA functions visible to the
Project
engine?
Public Function intLaunchMinusDays(datTaskStart As Date) As Integer
intLaunchMinusDays = ActiveProject.Tasks("Launch").Start -
datTaskStart
End Function
What I was trying to do was have a number field contain a
calculation
showing the number of calendar days from the start of each task to
a
specific
task. In my case, the task titled "Launch" is the reference point.
If
there
is a non-VB way to do this I would be open to that as well. I just
didn't
see an obvious way to get there otherwise.
scabhead,
Many of the functions and methods used in VBA are also available for
use
in custom fields. However the things that can be done in custom
fields
are very limited compared to VBA code. Furthermore, a formula in a
custom field can only operate on project level field data (e.g.
Project
Start Date) or field data for that task only. For example, you cannot
reference the contents of task 30's start date in a formula for task
10.
For what you want to do use VBA. It will be a lot simpler.
John
Project MVP