Getting list of Project fields with TableFields

T

Toney

Hello. What's wrong with my code? I want to retieve a list of all the fields
in Project 2007, using the following code. What is my object problem?

Sub GetFields()
Dim tField As TableField, fNames As String
Set tField = TableFields.TableField ' I get "object require" on this.

For Each tField In TableFields
fNames = fNames & tField.TableField & vbCrLf
Next tField

MsgBox fNames
End Sub
 
R

Rod Gill

There isn't a way to list all fields, but this code lists all fields in a
table:

Sub Fields()
Dim fld As TableField
For Each fld In ActiveProject.TaskTables("Entry").TableFields
Debug.Print Application.FieldConstantToFieldName(fld.Field)
Next fld
End Sub


--

Rod Gill
Microsoft MVP for Project

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

toney

Thanks, Rod. Is there a way to print out all the items in the pjField
enermation, vba or c#? That might help me. By the way, love your VBA book. I
always have it by on my desk.
 
R

Rod Gill

Hi,

Thanks for the feedback!

Not that I know of I'm afraid. I tried using a loop with the
fieldidtofieldname method but that didn't give the results I hoped for.

--

Rod Gill
Microsoft MVP for Project

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

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