Hiding Columns

H

Hacknwhack

I want to make sure that I display only specific columns in my gantt, so I
was wondering if there was a way to determine (within macro of course) what
columns were visible or a way to simple hide all columns. After that I
could simply add back in the ones I need and would always be assured to have
the same visible columns every time.

Thanks
-hack
 
J

JackD

Yes, you can always create and apply a view with whatever columns you want.
The easy way to see how to do this is to turn on the macro recorder and go
at it. Then look at the resulting code.
 
H

Hacknwhack

My question however was, is there a way to hide all columns in one swing. I
can not see how to do this through the GUI, so I'm not how the macro
recorder will help. I did use it to figure out how to hide and unhide
columns, but to ensure I don't miss hiding a column that may be present, I
figure some type of "hideall" or "selectall" function might exist.

-hack
 
J

John

Hacknwhack said:
My question however was, is there a way to hide all columns in one swing. I
can not see how to do this through the GUI, so I'm not how the macro
recorder will help. I did use it to figure out how to hide and unhide
columns, but to ensure I don't miss hiding a column that may be present, I
figure some type of "hideall" or "selectall" function might exist.

-hack

hack,
Hiding all columns and then adding back the ones you want is kinda like
draining the water out of the lake to go fishing - not very efficient.

Forget about trying to find out what fields (columns) are displayed,
just create your own custom view with the columns you want. Use the
TableEdit Method to customize the current view table or use a
combination of the ViewEditSingle and TableEdit Methods to create a
complete custom view. Check the VBA help file for the syntax of those
methods or take Jack's suggestion and record a macro while you create a
custom view.

Hope this helps.
John
Project MVP
 
J

jsl

(Went looking for a VBA book of the 2000 flavor, but no luck in my tech
library... so I'm in "ask a stupid question" mode...)

Okay... this is along the lines of my newest widget I got asked to
do...

So I defined a view through the View Toolbar called "XYZ Default View
Table" that's basically a minor customization of the default Task Entry
table.

then I made a little sub to apply the view, with the code

TableApply Name:="&XYZ Default View Table"

in it

Ran the little sub and it worked like a champ.

Changed the view to something like a resource sheet, ran my little sub
again and I get an error 1101, "The view or report cannot be displayed
because the table "&XYZ Default View Table" on which it is based has
been deleted."

But the XYZ Default View Table is still there... I can select it
manually by changing back to a Schedule View then selecting the XYZ
Default View Table from the View/Table menu.

Now, I am assuming that this is because when I changed my view manually
to a resource sheet to do some more testing, my project was no longer
using the same grouping or hierarchy of tables (i.e. it was using
tables from the Resource grouping instead of tables from the Task
grouping)....

Based on this, can I safely assume that within my little sub, the smart
thing to do first is to check the TableType property to see if I'm
dealing with a Task Item (pjTaskItem in the VBA 2003 help file I
acquired... not sure if this constant works for VBA 2000).

or would it be better to go straight to doing a TableEdit Name:="XYZ
Default Task Table", TaskTable:=True, then the TableApply?

--jsl
 
J

John

Jennifer,
Just for reference, you are a little cryptic in your opening statements.
For example, in my world a "widget" is a tangible thing (i.e. a piece of
hardware) not an intangible like a task (i.e. "... widget I got asked to
do?)

I doubt you will find a book on VBA for a specific version of Project.
The best reference I know can be found on the MVP website at:
http://www.mvps.org/project/links.htm
Look at the bottom of the page for, "Project 98 Visual Basic Environment
Training Materials". Even though it says it is for Project 98, the
material is equally applicable to all later versions. The only real
difference for VBA is that in later versions the object model is
expanded. Object model changes can be reviewed by looking at the VBA
help files for whichever version of Project you are using.

I think you already discovered the problem with your approach. Task
views and Resource views each have an associated table that describes
which Project field to display in which column. And just like the spare
fields, view tables are unique to the view type. For example, in your
case the "&XYZ Default View Table" is indeed missing when you are
dealing with the Resource Sheet because that table is a Task table.

Personally I wouldn't mess with checking the TableType property. I would
simply use TableEdit to create the appropriate table for the view of
interest, be it Task or Resource.

Hope this helps.
John
Project MVP
 
J

jsl

John --

Yes. I figured out my problem ... sometimes I think just the act of
describing the problem in a posting or e-mail helps clear the fog.

I've been working my way through the VBE training materials plus
copying some of the examples from the SDK and stepping through them in
and out of Debug to get a better handle on how things are working.

Sorry for using the word "widget"... Over the years I've tended to use
"widget" as a catch-all word, and forget that not everyone uses it with
the same meaning.

--jsl
 

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