Object reference for assignment identifier

M

Mark VII

Hello --

I'm working on a program that would allow certain project file inputs
(notably Work) to be updated in Excel and then batch posted back into
Project. I need to write out an identifier for each task (which is not a
problem) and an identifier for the assignment of each resource to the task so
I can find it and update it later (which is the problem).

What's got me chasing my tail is whether to use the task object, resource
object or the assignment object, and what would give me a unique identifier
for the assignment of a resource to a task.

Nothing I've tried for this has worked. Instead of trying to catalog my
unsuccessful attempts, I was hoping someone has done this before and could
point me in the right direction. Any ideas?

Thanks,
Mark
 
R

Rod Gill

Use UniqueID for Tasks, Resources and Assignments. Those values are unique
for each project (each Project has a TaskUniqueID o1 etc.)

To use a Task object with a Task UniqueID stored in a variable called TID
use:

Dim TUID as Long
Dim RUID as Long
Dim AUID as Long
Dim Tsk as Task
Dim Res as Resource
Dim Assgn as Assignment

'Your code to read UIDs

Set Tsk=ActiveProject.Tasks.UniqueID(TUID)
Set Res=ActiveProject.Resources.UniqueID(RUID)
Set Assgn=activeproject.Tasks.UniqueID(TUID).Assignments.UniqueID(AUID)

--

Rod Gill
Project MVP

Project VBA Book, for details visit:
http://www.projectvbabook.com

NEW!! Web based VBA training course delivered by me. For details visit:
http://projectservertraining.com/learning/index.aspx
 
J

John

Mark VII said:
Hello --

I'm working on a program that would allow certain project file inputs
(notably Work) to be updated in Excel and then batch posted back into
Project. I need to write out an identifier for each task (which is not a
problem) and an identifier for the assignment of each resource to the task so
I can find it and update it later (which is the problem).

What's got me chasing my tail is whether to use the task object, resource
object or the assignment object, and what would give me a unique identifier
for the assignment of a resource to a task.

Nothing I've tried for this has worked. Instead of trying to catalog my
unsuccessful attempts, I was hoping someone has done this before and could
point me in the right direction. Any ideas?

Thanks,
Mark

Mark,
Yeah, the three Project objects can really make you chase your tail.
Here is one structure that should help.

Sub DoAssignments()
Dim t As Task
Dim a As Assignment
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
For Each a In t.Assignments
MyVar = t.ResourceName
[do stuff with MyVar or whatever]
Next a
End If
Next t
End Sub

John
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