Is Field Visible in CurrentTable

J

Johhny

How do you determine if a particular field is visible in a table. In
particular, I'm looking for field Number15 in a resource table.

MS Project 2003
 
M

Mike Glen

Hi Johhny,

Welcome to this Microsoft Project newsgroup :)

View/Table: ()/More Tables... and in the dialog, select the table you want
and click the Edit button. This will list all the fields (columns) shown in
that table.

FAQs, companion products and other useful Project information can be seen at
this web address: http://project.mvps.org/faqs.htm

Hope this helps - please let us know how you get on :)

Mike Glen
MS Project MVP
See http://tinyurl.com/2xbhc for Project Tutorials
 
J

Johhny

Sorry, I neglected to say I want to do this in VBA.
--
Johnny



Mike Glen said:
Hi Johhny,

Welcome to this Microsoft Project newsgroup :)

View/Table: ()/More Tables... and in the dialog, select the table you want
and click the Edit button. This will list all the fields (columns) shown in
that table.

FAQs, companion products and other useful Project information can be seen at
this web address: http://project.mvps.org/faqs.htm

Hope this helps - please let us know how you get on :)

Mike Glen
MS Project MVP
See http://tinyurl.com/2xbhc for Project Tutorials
 
R

Rod Gill

I don't think you can read the current columns, leastwise there is no hint
of how to do this in the Object Browser. The work around is to always build
and re-build the table you want that holds just the columns you want. That
way you always know what columns are visible.

Record a macro of you creating a table (including your Number15) then use
the recorded code in your macro.

--

Rod Gill
Project MVP

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

NEW!! Web based VBA training course delivered by me. For details visit:
http://projectservertraining.com/learning/index.aspx


----------------------------------------------------------------------------------------------------


Johhny said:
Sorry, I neglected to say I want to do this in VBA.
 
J

Johhny

I'm writing this macro to insert a field into projects at other locations in
our company. I had wanted to see if I could find the Number15 resource field
if it is visable and replace it with Duration1 on the resource sheet. I
couldn't find a way to determine if the Number15 field was visible and your
response confirms that it doesn't look possible. I'll just append the new
fields to their current table on the resource sheet and give them
instructions on which fields to hide. Thanks very much for the help.
 
J

John

Rod Gill said:
I don't think you can read the current columns, leastwise there is no hint
of how to do this in the Object Browser. The work around is to always build
and re-build the table you want that holds just the columns you want. That
way you always know what columns are visible.

Record a macro of you creating a table (including your Number15) then use
the recorded code in your macro.
Rod,
No so my friend. I just wrote a macro for a client that does exactly
that. It "reads" the fields in the current view and exports the data for
those fields to Excel. It also replicates the Project column width,
alignment and font size. It took me a little while to work out the
"read" statements, but it is very doable.

John
Project MVP
 
J

John

Johhny said:
Can you give an example of how you determine which fields are in a view?
Johnny,
I wasn't sure if you would see the reply I gave to Rod.

Use the FieldIDList Property of the Selection object. From there you can
get various parameters for fields shown as columns in the visible view
(e.g. column name, width, etc.). Remember that a column in a Project
view can have one of three labels, the field name, the column title, or
a custom name.

Hope this helps.
John
Project MVP
 
J

Johhny

Thanks John

This is what I came up with:

ViewApply "Resource View"
SelectRow row:=ActiveProject.Resources(1).ID, rowrelative:=False
For X = 1 To ActiveSelection.FieldNameList.Count
Debug.Print ActiveSelection.FieldNameList(X)
Next

It works great. I couldn't figure out what to do with the ID numbers
returned by the FieldIdList. Could you explain how to use the ID numbers?
 
J

John

Johhny said:
Thanks John

This is what I came up with:

ViewApply "Resource View"
SelectRow row:=ActiveProject.Resources(1).ID, rowrelative:=False
For X = 1 To ActiveSelection.FieldNameList.Count
Debug.Print ActiveSelection.FieldNameList(X)
Next

It works great. I couldn't figure out what to do with the ID numbers
returned by the FieldIdList. Could you explain how to use the ID numbers?
Johnny,
As I'm sure you note, the value returned by the FieldNameList property
is the numeric constant for the selected field. To find the field name
use the FieldConstantTofieldName Method. For example, let's say the
selected field cell is in the Task Text1 field. The list property will
return a value of: 188743731. If you then use that as an argument for
the FieldConstantToFieldName Method, it will return "Text1".

John
Project MVP
 
J

Johhny

Excellent! Thanks for the help.
--
Johnny



John said:
Johnny,
As I'm sure you note, the value returned by the FieldNameList property
is the numeric constant for the selected field. To find the field name
use the FieldConstantTofieldName Method. For example, let's say the
selected field cell is in the Task Text1 field. The list property will
return a value of: 188743731. If you then use that as an argument for
the FieldConstantToFieldName Method, it will return "Text1".

John
Project MVP
 
J

Johhny

This is my final solution to find the field names in a table. Thanks to
everyone who responded to my question.

Sub FindTableFieldNames()
'Find the field names in a table
'This example is a resource table
Dim fName As Variant
ViewApply "Resource Sheet"
'TableApply "A Specific Table"
SelectRow Row:=1, RowRelative:=False
For Each fName In ActiveSelection.FieldNameList
Debug.Print fName
Next fName
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