How Can I get column name?

Z

Zoo

Hi,
The following code enumerates the field id.
I want to know a field name like 'Task Name' , 'Duration' from the field id.
How can I get the name?

Sub Test()
Dim i As Long
Dim id As Long
Dim ColumnName As String
For i = 1 To ActiveProject.TaskTables(1).TableFields.Count
id = ActiveProject.TaskTables(1).TableFields(i).Field
Debug.Print i, id
ColumnName = "" 'I dont't know how to get this from id.
Next
End Sub

-- Result --
1 188743703
2 188743885
3 188743694
4 188743709
5 188743715
6 188743716
7 188743727
8 188743729
 
R

Rod Gill

Hi,

This group is closing down, so please use teh project.developer group in
future.

Try:
Sub Test()
Dim Tsk as Task
For Each Tsk in ActiveProject.Tasks
If Not Tsk Is Nothing Then
Debug.Print "ID: " & Tsk.Id, "Name: " & Tsk.Name, "Duration: " &
Tsk.Duration/60/ActiveProject.HoursPerDay &"d"
End if
Next Tsk
End Sub


--

Rod Gill
Project MVP

NEW!! Project VBA Book, for details visit: http://www.projectvbabook.com
 
Z

Zoo

Thank you for your relpy.
I will use the group when I post a new topic.

I'm sorry , I failed to describe what I wan to know in the mail well.

Debug.Print "Name: " & Tsk.Name

Can the code above be written in another way from the view point of "Name:
" ?

Debug.Print SomeFunction(pjTaskName) & Tsk.GetField(pjTaskName)


SomeFunction(ByVal FieldID as PjField) should return the field's name.
 
Z

Zoo

Thank you so much, Rod!
FieldConstantToFieldName is exactly what I want.

SomeFunciton is no more necessary for me.
 

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