Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-06-13
4
Medium Priority
?
1,557 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:
Dr. Thomas Henkelmann earned 1080 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:Dr. Thomas Henkelmann
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

At the office, we’ve started to get serious about organizing what we’re doing. I mean, it was getting to the point where every time I received a phone call, it began with “I know you’re really busy, but…” My boss was taking tasks away from me left a…
Learn how ViaSat reduced average response times for IT incidents from 10 minutes to 30 seconds.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

927 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