Reading Assignment Enterprise Custom Field Values with VBA

January 24, 2008 @ Project Programmability from Chris Boyd

Vote This Post DownVote This Post Up (No Ratings Yet)
Loading ... Loading ...


Hello,

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:

http://www.microsoft.com/downloads/details.aspx?FamilyID=cec3e1e2-d802-4a03-bc78-05c48472559b&displaylang=en

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


This article is syndicated from Project Programmability . The original article is available here. Read more in Project Management News, Project Programmability .

No tag for this post.
Popularity: 8%
Reminder : PMToolbox has ZERO tolerance to copyright violation and agrees to follow strictly PMI's Professional Responsibility. That's why each post on this site includes a link to the original version at its source site.

Comments

2 Responses to “Reading Assignment Enterprise Custom Field Values with VBA”

  1. James on June 3rd, 2008 10:25 pm

    How do I change (programmatically via VBA) the setting between showing the data or a graphical indicator for an Enterprise Custom field?

    • James on June 3rd, 2008 10:27 pm

      How do I set up and handle events from CommandBarButtons?

      Got something to say?






      [?]