Forum Discussion

Jasonzhengzx0204's avatar
Jasonzhengzx0204
Copper Contributor
Sep 12, 2026
Solved

Regarding the usage of PjAssignmentField in Microsoft Project

Hello, the following code is placed in the ThisAddIn class of a Project VSTO add-in. I want to execute other code when the field Text1 corresponding to the resource assigned under a task changes. The problem I am currently encountering is:
When the Text1 corresponding to the resource assignment under a task changes, the message box "OK" does not pop up. However, in the "Resource Usage" view, when the Text1 of the task assignment under a resource changes, the message box "OK" does pop up.
I hope experts can provide guidance.

    Private Sub ProjectBeforeAssignmentChange(asg As MSProject.Assignment, Field As MSProject.PjAssignmentField,
                NewVal As Object, ByRef Cancel As Boolean ) Handles Application.ProjectBeforeAssignmentChange
        If Field = MSProject.PjAssignmentField.pjAssignmentText1 Then
            MsgBox("OK", vbExclamation)
        End If
    End Sub

2 Replies

    • Jasonzhengzx0204's avatar
      Jasonzhengzx0204
      Copper Contributor

      Hi John,

      I can see your wiki, and the solutions in it are really valuable. The code cleverly solves the information sharing of Text between Job, Task_As, and Reso_As. Task field information often needs to be passed to the Task Usage view or Resource Usage view to enable filtering, grouping, and other applications.

      My current needs are a bit different. I'd like to use the uploaded code to capture changes in the blue cells in the Task Usage view and then run the relevant code, as shown in Figure 1.

      The current problem is that in the Task Usage view, when the text1 corresponding to Task_As changes, "OK" does not pop up.

      However, in the Resource Usage view, when the text1 corresponding to Reso_As changes (the green cell in Figure 2), "OK" does pop up. I haven't found a solution yet.

      Best regards.

      Figure 1.

      Figure 2