Changing booking type errors on multiple projects

S

Sam

I have written the following code to change the resource booking type from
'Proposed' to 'Committed' for each resource in a project:

For Each res In ActiveProject.Resources
res.BookingType = pjBookingTypeCommitted
Next res

This works perfectly if only one project is open at a time but errors out if
I have more than one project open. Any ideas on why it errors and how to fix
it?

Thanks,
Sam
 
S

Sam

After investigating some I found that even though I am calling for resources
on only active projects that the API was trying to change the booking type
for all resources across all projects. Since not all resources were on the
project teams for all projects the code errored. A simple work around that I
found was to scroll through each task on the active project and if a resource
was located then it would change their booking type.

Here is the code:

Dim tsk As Object, res As Object

For Each tsk In ActiveProject.Tasks
If Not tsk Is Nothing Then
For Each res In tsk.Resources
res.BookingType = pjBookingTypeProposed
Next res
End If
Next tsk

Enjoy,
Sam
 

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