copy text fields

C

CB

I am using MSOP 2007 standard. I cannot get the following code to work:

Sub PortfromGantttoResource()

Dim t As Task
Dim ts As Tasks
Dim A As Assignment
Set ts = ActiveProject.Tasks
For Each t In ts
If Not t Is Nothing Then
For Each A In t.Assignments
A.Text2 = t.Text2
Next A
End If
Next t
End Sub

I am trying to get the gantt view text 2 field copied to the resource text 2
field. Any ideas on what is wrong here. I have used this in MSP 2002
without any problems.
 
J

Jan De Messemaeker

Hi,
This is an oddity (to say the least) of Project 2007
The assignment object seems to have all custom fields twice

The following code is (a) horrible and (b) untested but I think it will do
the trick:

Sub PortfromGantttoResource()

Dim t As Task
Dim ts As Tasks
Dim A As Assignment
Dim A1 As Assignment
Dim Reso as resource
Set ts = ActiveProject.Tasks
For Each t In ts
If Not t Is Nothing Then
For Each A In t.Assignments
A.Text2 = t.Text2
set reso=activeproject.resources (A.resourceID)
for each A1 in reso.assignments
if A1.taskid=t.id then
A1.text2=t.text2
exit for
end if
next A1
Next A
End If
Next t
End Sub

Hope this helps

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
 

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