VBA 2003 to 2010

F
Fabian Breu 👤 Member for 14 years 7 months

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

 

A
ali deveboynu 👤 Member for 16 years 2 months

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 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
 
 and run this script manually 
 
best regards.
I
Ismet Kocaman 👤 Member for 16 years 3 months

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

Regards,

Ismet

Forum Sponsor

Top Posters

Julian Pegg
1 posts
Peter Nagy
2 posts
Raymund de Laza
17 posts
Syed_Asad
0 posts
Tony Greyvenstein
0 posts
Ahmed Al-Jubouri
13 posts
Umar Alvi
3 posts
Sibusiso Mahlalela
0 posts
Michael Samanyayi
3 posts
Simon Gumede
0 posts