Solved

Project 2010 - copy data from custom text in task to custom text in assignment?

Posted on 2013-06-13
4
1,285 Views
Last Modified: 2016-10-04
Using MS Project 2010 we would like to copy custom text field contents from tasks to assignments. A coworker wrote the accompanying macro to do this in version 2003. It doesn't work in 2010. Any insights for someone who doesn't write Project VBA code?

Dim t As task
Dim a As Assignment
On Error Resume Next
    For Each t In ActiveProject.tasks
        For Each a In t.Assignments
            a.Text1 = t.Text1
            'Change above numbers to use alternate text fields.
        Next a
    Next t
End Sub

Open in new window

0
Comment
Question by:Shannon Mollenhauer
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
thausla earned 270 total points
ID: 39246866
Hi,

in 2010 you are having TWO assignment text fields - one for tasks views and for resource views. Sounds crazy but that's how it works. If you want to use the text fields in a Resource Usage view, you need to use the RESOURCE text fields at assignment level:
---
Sub CopyTaskToAssn()

    Dim oTask As Task
    Dim oAssn As Assignment
    Dim oRes As Resource
   
    For Each oTask In ActiveProject.Tasks
        If Not oTask Is Nothing Then
            For Each oAssn In oTask.Assignments
                For i = 1 To ActiveProject.Resources(oAssn.ResourceName).Assignments.Count
                    If ActiveProject.Resources(oAssn.ResourceName).Assignments(i) = oAssn.UniqueID Then
                        ActiveProject.Resources(oAssn.ResourceName).Assignments(i).Text1 = oTask.Text1
                        ActiveProject.Resources(oAssn.ResourceName).Assignments(i).Text2 = oTask.Text2
                        ActiveProject.Resources(oAssn.ResourceName).Assignments(i).Text3 = oTask.Text3
                        ActiveProject.Resources(oAssn.ResourceName).Assignments(i).Text4 = oTask.Text4
                        ActiveProject.Resources(oAssn.ResourceName).Assignments(i).Text5 = oTask.Text5
                        Exit For
                    End If
                Next
            Next
        End If
    Next
End Sub
---

Hope this helps

Thomas
0
 

Author Comment

by:Shannon Mollenhauer
ID: 39263127
Thanks for the code. I'll try this and see if it accomplishes what we're after. I wasn't aware of 2 different sets of fields. Interesting.
0
 

Expert Comment

by:Alex Lizana
ID: 41812565
Hi Thomas
It works very good, however when I have a lot of tasks the script take a long time to compleate the copy of Texts, please I need to support, how I can improve this script.
Best Regards.
0
 
LVL 12

Expert Comment

by:thausla
ID: 41828573
Hi,

the time for the code to loop through all the tasks in a project unfortunately grows exponentially with the number of tasks, we have seen this for a long time for similar functions. Could you please give me some rough numbers: how many tasks, how many resources assigned in average, how long does the execution take?

Regards

Thomas
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: x-men
Where used to see Gantt charts for illustrating project timelines, but what if I wanted to visualize passed timed events? Here's how.
Online collaboration is quickly becoming embedded in the workplace, and its benefits are tangible. See what the current landscape looks like and what the future holds for collaboration tools and the future of work.
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now