All the Fields in a Table

N

Newbie

Hello,
How can we read (wiht VBA) all the fields which are displayed in a Project
Table ?
Thanks
 
J

Jan De Messemaeker

Hi,

SelectAll
Activeselection.fieldnamelist or
Activeselection.fieldidlist
HTH
 
N

Newbie

One more explanation : I want to read the *names* of the fields in the
table.
I can read the titles but not the names...
 
J

Jan De Messemaeker

Too bad, it works for me and in different versions of Project!
- You're talking about Project, not about Server I hope? I know almost
nothing about Server
- When you fire selectall, you are in the right view I hope?
But it definitely, absolutely works.
 
L

LtLeary

This ain't pretty but looks like it works (at least in my limited
tests)

The problem with the "fieldNameList" is that it returns a TITLE if one
exists and a NAME if not
The "TableFields" collection will only return the TITLES and No Names.
Well, shoot, so l figure, lets delete the Title (temporarily) and then
get the name (we can always set the title back)
I had to issue a "window refresh" to get it to work and you may find a
lot of other "gotcha's" but it may help give you some other ideas...

Lt

Sub Checkitout()
x = ActiveProject.CurrentTable
'current table and current view should be same..just don't use on
custome views

Application.SelectAll
intcounter = ActiveProject.TaskTables(x).TableFields.Count

For i = 1 To intcounter
strTitleOnly = ActiveProject.TaskTables(x).TableFields(i).Title
StrName = ActiveSelection.FieldNameList(i - 1)

If strTitleOnly <> "" Then
'We know we have a Title field
'So get rid of it
ActiveProject.TaskTables(x).TableFields(i).Title = ""
Application.ActiveWindow.Refresh
'refresh the selection list
Application.SelectAll
'You should be left with the NAME and not the TITLE

strYouWantedTheName = ActiveSelection.FieldNameList(i - 1)
'lets not forget to set the Title back to normal
ActiveProject.TaskTables(x).TableFields(i).Title = strTitleOnly
Else
'if the title is "" then you know you have the name allready
strYouWantedTheName = StrName

End If
MsgBox strYouWantedTheName

Next i

End Sub
 

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