How to find the number of values under a custom field(lookup value

N

Navaneeth

I have created a asp.net website using C# which takes a ms project file as an
input and reads the data from the mpp file.
In the mpp file I have a column which is a custom field(Text1) and has a
lookup values in it(Entries for cells in the column are limited and can be
selected only from drop down). For eg, I have a column called color and the
column can consist of only RED or BLUE or GREEN. So the column has a look up
value with the three colors in it.

I create an interop object for ms project and I also open the file. SO here
is how it goes.



using Microsoft.Office.Interop.MSProject;


ApplicationClass appSampleProject = new ApplicationClass();

bool bOpen = appSampleProject.FileOpen(fileName, true,
PjMergeType.pjDoNotMerge, oMissing, oMissing, oMissing, oMissing, oMissing,
oMissing, oMissing, oMissing, PjPoolOpen.pjDoNotOpenPool, password, oMissing,
oMissing, oMissing);

Project proSample = appSampleProject.ActiveProject;





So before I loop through the tasks, I want to get the count of predefined
values present in the column and the values. I know how I can get the
values. This is how I get.



proSample.Application.CustomFieldValueListGetItem(PjCustomField.pjCustomTaskText1,PjValueListItem.pjValueListValue,1)
So in the above code I mention that I need to get the value for the custom
field(Text1) at index position 1

But how can I find the total count of predefined values present in the
column by using only the project object and without looping through tasks
individually.
 
R

Rod Gill

I think you need to loop thru all CustomFieldValueListGetItem values until
you get an error (gone past last item).

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 
N

Navaneeth

Thanks for the reply Rod Gill. But I had got this idea sometime back where I
can loop through untill an exception is generated and I could handle the
exception. But I was trying for a way out without generating an exception.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top