locked
MS Project VBA - Assignment custom fields when task is unassigned? RRS feed

  • Question

  • Hi, (MS Project 2003)

    I want to programmatically set the Text1 field for all assignments, including those that are unassigned. (You might think there's no such thing as an unassigned assignment, but if you add column Text1 to, say the resource usage view you will find that you can enter values for all assignments, including those where the resource is unassigned, and all the values are retained. Further, if you export the whole project to Access, you will find that there are rows for these in the MSP_ASSIGNMENTS table, with RES_UID=-65535).

    As far as I can see, the only way in the object model to get at an assignment object is via task or via resource. But mytask.assignments only includes items where resource has been assigned, and (hardly surprisingly) there's no resource object for the null resource.

    So, the question:
    Is it posible to access this data via the object model, and if so how? If not, then is there some other way?

    It occurs to me that it might work to (programmatically) assign a dummy resource to all unassigned tasks, set the field, and then explicitly reset the resource ID in the assignment object to the unassigned value. But I think this might have unpleasant side effects.

    Many thanks for all suggestions,
    Alan.

    ps if it helps to be clear, the following code successfully sets the text1 field for all assignments which do have resource, but I want to do the same where the resource usage view shows resource as Unassigned.

    Dim myTask as Task
    Dim myAssignment as Assignment

    For Each myTask  in ActiveProject.Tasks
    If Not myTask Is Nothing Then
    For Each myAssignment in myTask.Assignments
    myAssignment.Text1 = "some specific value"
    Next myAssignment
    Next myTAsk

    (Obviously for real I'm not setting these all to the same value.......)

    • Moved by Tim Li Monday, September 7, 2009 6:21 AM off-topic (From:Visual Basic for Applications (VBA))
    Wednesday, August 12, 2009 2:42 PM

All replies

  • Hello Alan,

    As you can see there's no one replied your question yet, I think the reason is this fourm is mainly discuss the questions about VBA itself, and your question is more related to Project Object Model, to this specific question I suggest you also ask it in Project newsgroup, where you'll get more help from the experts on Project.

    The address to the  Project newsgroup please refer to this link:
    http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.project.developer&lang=en&cr=US



    Thanks

    We have published a VSTO FAQ recently, you can view them from the entry thread VSTO FAQ.
    If you have any feedbacks or suggestions on this FAQ, please feel free to write us emails to colbertz@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, August 19, 2009 6:06 AM
  • Hello Alan,

    As you can see there's no one replied your question yet, I think the reason is this fourm is mainly discuss the questions about VBA itself, and your question is more related to Project Object Model, to this specific question I suggest you also ask it in Project newsgroup, where you'll get more help from the experts on Project.

    The address to the  Project newsgroup please refer to this link:
    http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.project.developer&lang=en&cr=US



    Thanks

    We have published a VSTO FAQ recently, you can view them from the entry thread VSTO FAQ.
    If you have any feedbacks or suggestions on this FAQ, please feel free to write us emails to colbertz@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, August 19, 2009 6:07 AM