How to get expanded or collapsed state of task

B

billb

I'd like to iterate over the task list and determine whether or not a task is
expanded or collapsed. I see where I can tell Project to expand or collapse
but don't see where I can ask if it's expanded or collapsed. Is this
possible?

Thank you in advance.
 
J

John

billb said:
I'd like to iterate over the task list and determine whether or not a task is
expanded or collapsed. I see where I can tell Project to expand or collapse
but don't see where I can ask if it's expanded or collapsed. Is this
possible?

Thank you in advance.

bilb,
Yes but not directly. There are several properties that can be set via
VBA but not read. Therefore some type of indirect method must be used.
For example, in your case I would iterate through the project file and
look at the ID field. When you find a missing ID or group of IDs, you
will know that the summary is collapsed. Of course you must first make
sure no filters or sort is applied for this method to work.

Hope this helps.
John
Project MVP
 
B

billb

Thank you John. This was helpful. I'm a bit unclear on one thing though.
If I iterate over all tasks and save off the ID, what am I iterating over the
second time to make the comparison?

Thank you again.
 
J

John

billb said:
Thank you John. This was helpful. I'm a bit unclear on one thing though.
If I iterate over all tasks and save off the ID, what am I iterating over the
second time to make the comparison?

Thank you again.

billb,
You don't iterate twice. For example, if the first ID is 1 but the next
ID is 10, you can deduce that task one is a summary line and it's tasks
(i.e. IDs 2 through 9) are collapsed.

Oh, one more little tidbit. In order for this process to work you will
need to use the following code structure. That will only iterate over
the current visible tasks in the view.
SelectTaskColumn
For Each t in ActiveProject.Selection
[store each ID and compare with the previous ID]
Next t

John
Project MVP
 

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