Assignments

S

SonT

Hello,

I do not understand why this code is incorrect. Please advise.

dim b as assignment
for each b in activeproject.tasks.assignments
msgbox b.resourcename
next b

Thanks
 
R

Rod Gill

Hi,

The problem is that the collection Tasks does not have any assignments.
Individual tasks have assignments. I would write this code:

Sub ListAssignments()
Dim Assgn As Assignment
Dim Tsk As Task
For Each Tsk In ActiveProject.Tasks
If Not Tsk Is Nothing Then 'Test for blank lines
For Each Assgn In Tsk.Assignments
Debug.Print Tsk.Name, Assgn.ResourceName
Next Assgn
End If
Next Tsk
End Sub


Debug.Print writes the result to the immediate window. In the VBA editor
press Ctrl+G to see it
--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 

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