Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Project Task Field for reporting

Status
Not open for further replies.

DrSimon

IS-IT--Management
Dec 14, 2001
674
GB
Hi
I am trying to do some variable reporting using VBA with MS Project. I want to extract all task fields (i.e. those fields that appear when you insert a column) in order to create a drop down list of them as options and then use that selection to extract data from the project tasks. I have looked around but I can't get anywhere - everything I find doesn't do the job. can anyone help please? I'm OK with coding when fields are hard coded e.g. Task.ActualCost or Task.Name but cant' get any deeper.
 
Hello Dr. Simon,

I'm afraid I can't find the question in here. Are you looking for a list of Task fields in Project?

I'd start with the Task Export Table map which exports the first 256 fields.

Julie

 
Thanks for replying Julie. I'll try to explan better.
When you are in the Gantt Chart view and insert a column, the Column Definition window appears with a dropdown list for Field name. Initially what I want is to be able to do is get to the contents of that dropdown list via VBA.
Thanks
Simon
 
Ah, I understand. I am not a VBA person by any stretch -- I can point you to a list of task fields, but I don't know how to enumerate the list in VBA.

You might have success posting to the Microsoft Forum for customization and see if someone there may weigh in.

For the Microsoft customizations forum see:
 
It isn't clear what possible use you could make of the dropdown list of all possible fieldnames. On the other hand, once the new column has been selected and inserted into the view then it makes sense to know what fieldnames have been selected for that view. Is that what you mean?

You should be aware, too, that different views use different tables and the different tables have different fieldnames.
 
Thanks both of you.
Julie - it's rare to be pointed to a forum that seems to provide quality replies up to tek-tips standard.
PDQ - I was hoping you'd look at this. You're right what I really need is not all possible fieldnames, but all fieldnames in use in a given table.
After a quick look at the forum Julie pointed me to, I consider that the methods FieldConstantToFieldName and Getfield are the ones I should be concentrating on. Does that seem right?

Simon
 
This code works in P2010 ... I *think* but haven't tested it, that it does NOT work in P2007 and earlier versions.

For i1 = 1 To oTbl.TableFields.Count - 1
strTempColTitle = FieldConstantToFieldName(oTbl.TableFields(i1).Field)
Next

 
Thanks again. I'm currently stuck with 2003, but probably moving to 2010 soon.

Simon
 
I may still have some P2003 code ... I'll check tomorrow.
 
P2003 code ... this will get the column names:

For iFldLoop = 1 To MSProject.ActiveSelection.FieldNameList.Count
strFieldName = MSProject.ActiveSelection.FieldNameList.Item(iFldLoop)
Next
 



something like this?
Code:
Sub test()
    Dim oTbl, oFld
    
    For Each oTbl In ThisProject.TaskTables
        For Each oFld In oTbl.TableFields
            Debug.Print oTbl.Name, oFld.Title, oFld.Field
        Next
    Next
End Sub

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Hey guys - thanks for all the feedback. In the interim I got round this by doing it all manually. However I can well see the need to do this in the future. I'll give feedback if/when that happens.

Simon
 
@Skip

Sorta.

The request was for field names, not field contents so the last item in your debug.print statement isn't correct.

Also, in P2010 there's a phantom field in several views that lets you simply select the fieldname that you want. That's why I have the .Count -1 code in my loop above.

HTH.

 


@PDQBach,
something like this?
I know next to nothing about MS Project, but a little bit about application objects.

Using the Watch Window and the Immediate Window results, one perhaps could deduce what objects are available and drill down to the desired data. It has helped me many times to start like this and EXPLORE. I am, however, no Magellan.


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top