Solved

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

Posted on 2013-06-13
4
1,306 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Re-planning is just as important as planning. MS Project files need to be updated regularly to reflect the current status of the project and to streamline the upcoming tasks. We have seen a lot of issues where project managers have not updated the p…
When we talk about DevOps toolchains, I sometimes wonder how many people really get what we’re talking about. I don’t know if it’s just semantics or tone or something else, but sometimes I think it just sounds like buzzword sausage. So it’s always …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

911 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

26 Experts available now in Live!

Get 1:1 Help Now