GanttStyle Enumeration?

P

Pete

I've been assigned to write a piece of code that will format outline level 2
summary tasks in different colors and patterns based on some key criteria in
the task name.

I'm using the GanttBarFormat method, and it works great. The problem I'm
having is dynamically figuring out what the GanttStyle parameter should be.

For example, if I create a new, blank Project and select "Bar Styles..."
from the "Format" menu I find that "Summary" is the 5th item in the list of
styles. I run the GanttBarFormat method with GanttStyle:= 5 and it works
wonderfully. However, if I then delete a style, or if I run the Gantt Chart
Wizard which deletes and rearranges all of the styles, "Summary" is no longer
the 5th entry in the list and my code breaks (for instance, the Gantt Chart
Wizard with all the default selections moves "Summary" to the 4th spot in the
list).

Does anyone know if there is a way to dynamically figure out where each
GanttStyle appears in the list?

Thanks for taking the time to think this through with me!

-Pete
 
J

Jan De Messemaeker

Hi,

I would use another approach altogether
I'd create a new style (the one you want to see) and set show for... Flag1
I'd set the summary as Summary; Not Flag1

Then in your coide just define when flag1 should be true.
BTW, GanttBarStyleEdit allows to address a bar style buy name or number.

Hope this helps,
 
P

Pete

Thanks Jan.

I can't change the requirements on my own, but I'll pass along your
suggestion and see if we can pursue that as an option.

Either way I'd still like to know how to extract the GanttStyle number from
the name. If I fire up the macro recorder and change the format of a Gantt
bar the code it produces always "knows" the right number for the selected
task. How does it know? It seems like there should be a way to figure out
the number if you know the name...

Any thoughts?

-Pete
 
J

John

Pete said:
Thanks Jan.

I can't change the requirements on my own, but I'll pass along your
suggestion and see if we can pursue that as an option.

Either way I'd still like to know how to extract the GanttStyle number from
the name. If I fire up the macro recorder and change the format of a Gantt
bar the code it produces always "knows" the right number for the selected
task. How does it know? It seems like there should be a way to figure out
the number if you know the name...

Any thoughts?

-Pete

Pete,
It "knows" because you told it when you selected the item.

There are several object properties in Project that are simply not
available in VBA. For example, you cannot "read" the font color. In
those cases some type of indirect approach must be taken.

A few months ago I had a similar scenario as yours. I needed to create a
set of bar styles using VBA. Unfortunately I found I could not "read"
the current bar styles so I took a different approach. I first deleted
all existing bar styles and then created the new set. Although that may
seem like a very inefficient way of doing it, it is probably the only
way.

One more thought. I also found that the Object Browser is rife with
errors regarding bar style descriptions. Very frustrating. In some cases
I had to record a macro just to find out what the proper syntax
variables were.

Hope this helps.
John
Project MVP
 
P

Pete

Thanks for the reply, John.

I was afraid there might not be a way to read the property.

I'm looking into deleting and rebuilding the styles now.

Given time constraints I may just train the user to open the Bar Styles
dialog box, count the rows, and enter the number in an input box.

Thanks again for your help.

-Pete
 
J

John

Pete said:
Thanks for the reply, John.

I was afraid there might not be a way to read the property.

I'm looking into deleting and rebuilding the styles now.

Given time constraints I may just train the user to open the Bar Styles
dialog box, count the rows, and enter the number in an input box.

Thanks again for your help.

-Pete
Pete,
You're welcome and thanks for the feedback.

John
 
J

Jan De Messemaeker

Hi,

You don't have to change the requirements, my suggestion does exactly the
same thing as your solution.
 

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