Solved

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

Posted on 2013-06-13
4
1,385 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
Dr. Thomas Henkelmann 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: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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Project VBA - Date and time stamp the date column 10 1,265
PMP prep 5 125
Project plan 6 494
Scrum Master: Certified Scrum Master 4 167
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…
"Disruption" is the most feared word for C-level executives these days. They agonize over their industry being disturbed by another player - most likely by startups.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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