Reading Assignment Enterprise Custom Field Values with VBA

Reading Assignment Enterprise Custom Field Values with VBA

  • Comments 3


There has been a number of people asking how to read assignment enterprise custom field values with VBA. In fact, we ran into this issue internally with our dogfood efforts and fixed it in SP1. So, if you need to get/set assignment custom field values, the first step is to download SP1:

Once you have SP1 installed, it is fairly easy to read assignment enterprise custom fields. When you read and set task and resource enterprise custom fields, you use the GetField and SetField methods in VBA. To read and set the assignment values you don't use the GetField and SetField, but instead use the name of the enterprise custom field as a property of the assignment.  There are a couple of caveats, however:

  • The field name can't contain spaces in the name
  • When you're writing your code, you won't get auto complete to show you the field name. This is because the property isn't a part of the type library and therefore isn't early bound.  As long as you pass in a valid field name, however, then the code will late bind to it. 

Here is a short example. Suppose your custom Field name is "ecfName", here is how you would read it:

For Each T in ActiveProject.Tasks

  If Not (T is Nothing) Then

    For Each A in T.Assignments

      assignCFVal = A.ecfName

    Next A

  End If

Next T

Chris Boyd

Leave a Comment
  • Please add 5 and 1 and type the answer here:
  • Post
Page 1 of 1 (3 items)