Solved

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

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

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…
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 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 …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

773 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