Guild of Project Controls: Compendium | Roles | Assessment | Certifications | Membership

Tips on using this forum..

(1) Explain your problem, don't simply post "This isn't working". What were you doing when you faced the problem? What have you tried to resolve - did you look for a solution using "Search" ? Has it happened just once or several times?

(2) It's also good to get feedback when a solution is found, return to the original post to explain how it was resolved so that more people can also use the results.

VBA 2003 to 2010

2 replies [Last post]
Fabian Breu
User offline. Last seen 12 years 43 weeks ago. Offline
Joined: 20 Oct 2011
Posts: 3
Groups: None

Hi

Tilll now i used the following macro to copy custom field content from the task tabelle to the assigment tabelle. So when i save the project it copy text5 from the gantt chart to text5 field in the ressource usage view.

 

This macro does not work in MS Project 2010. If i save the file als 2003 version it works more or less. It only works if delete the contant in text5 in the ressource usage and then save. So it does not perform updates.

 

I set the setting in the trust center to enable all macros.

what i wrong

Private Sub Project_BeforeSave(ByVal pj As Project)
Dim t As Task
Dim ts As Tasks
Dim A As Assignment
Set ts = ActiveProject.Tasks
For Each t In ts
    If (Not t Is Nothing) Then
        For Each A In t.Assignments
            'change the following line to use
            'for a different custom field
            A.Text5 = t.Text5
           
        Next A
    End If
Next t

End Sub

 

Replies

ali deveboynu
User offline. Last seen 11 years 25 weeks ago. Offline
Joined: 24 Mar 2010
Posts: 5

mr fabian 

ı just copy the text to global. mpt and it works , if you still have problems could you try to insert a new module and paste 

 

Private Sub Project_BeforeSave()Dim t As TaskDim ts As TasksDim A As AssignmentSet ts = ActiveProject.TasksFor Each t In ts    If (Not t Is Nothing) Then        For Each A In t.Assignments            'change the following line to use            'for a different custom field            A.Text5 = t.Text5                   Next A    End IfNext tEnd Sub  and run this script manually  best regards.
Ismet Kocaman
User offline. Last seen 8 years 44 weeks ago. Offline
Joined: 5 Mar 2010
Posts: 26

Could you pls verify you have SP1 and August Hotfix applied to Project 2010 ?

Regards,

Ismet