M
Mark VII
Greetings --
I'm working up a program to take a Excel list of tasks and resources and
bring it into Project. (We have a standard estimating Excel template that is
currently entered into Project manually, and am trying to automate this.) Am
having trouble assigning resources to tasks. Here's a high level of how the
code looks.
dim tsk as Task
dim rst as Resource
dim asn as Assignment
dim proj as Project
set proj as Application.Projects.Add
For each row on the input spreadsheet
set tsk = proj.tasks.add
tsk.Name = < task name from spreadsheet > '* this goes OK
proj.Resources.Add (< resource name from spreadsheet > ) '* this goes OK
lngResourceId = RetreiveResouceId(name) '* function to find resource
and get its id
'* trouble starts here
Set asn = tsk.Assignments.Add(tsk.ID, lngResourceId, <units from
spreadsheet>)
asn.Work = < hours from spreadsheet >
next input row
Creating the task records goes OK. So does adding the resource and
retrieving the resulting ID. Where it gets messy is creating the resource
assignments.
The "Set asn = tsk.Assingment...." gives 1101, The Argument Value is not
Valid if I retrieve the units value from the spreadsheet (even if it's 1).
However, the statement works OK if I hard code the units value to 1.
If I run with units hard coded to 1, and reach the "asn.Work = < value from
spreadsheet >" line, I get the 1101 error again.
Have searched high and low for an example of the correct way to specify
these values and come up dry. Does anyone have any suggestions?
Thanks a million.
Mark
I'm working up a program to take a Excel list of tasks and resources and
bring it into Project. (We have a standard estimating Excel template that is
currently entered into Project manually, and am trying to automate this.) Am
having trouble assigning resources to tasks. Here's a high level of how the
code looks.
dim tsk as Task
dim rst as Resource
dim asn as Assignment
dim proj as Project
set proj as Application.Projects.Add
For each row on the input spreadsheet
set tsk = proj.tasks.add
tsk.Name = < task name from spreadsheet > '* this goes OK
proj.Resources.Add (< resource name from spreadsheet > ) '* this goes OK
lngResourceId = RetreiveResouceId(name) '* function to find resource
and get its id
'* trouble starts here
Set asn = tsk.Assignments.Add(tsk.ID, lngResourceId, <units from
spreadsheet>)
asn.Work = < hours from spreadsheet >
next input row
Creating the task records goes OK. So does adding the resource and
retrieving the resulting ID. Where it gets messy is creating the resource
assignments.
The "Set asn = tsk.Assingment...." gives 1101, The Argument Value is not
Valid if I retrieve the units value from the spreadsheet (even if it's 1).
However, the statement works OK if I hard code the units value to 1.
If I run with units hard coded to 1, and reach the "asn.Work = < value from
spreadsheet >" line, I get the 1101 error again.
Have searched high and low for an example of the correct way to specify
these values and come up dry. Does anyone have any suggestions?
Thanks a million.
Mark