locked
Working with gantt bar styles RRS feed

  • Question

  • Hi all,

    I want to create a bar style for tasks on the critical path and I've done so (associating a style with Flag2...).  I recorded a macro while doing so and got:

     

    GanttBarEditEx Item:="-1", Create:=True, MiddleShape:=1 '-1 = new
    GanttBarEditEx Item:="41", MiddlePattern:=0
    GanttBarEditEx Item:="41", MiddlePattern:=1
    GanttBarEditEx Item:="41", MiddleColor:=255
    GanttBarEditEx Item:="41", ShowFor:="Flag2"
    GanttBarEditEx Item:="41", Name:="CriticalTask"

     

    Is there a way to check the existing styles to determine if "CriticalTask" already exists so I can check and only create it if it doesn't?  There's that nice Item:=41 there but I can't find any way to either get the number or search for the name...

    Neglected to mention that this is in 2010.

    Thanks,
    Eric


    • Edited by RunDeep Tuesday, January 17, 2012 12:51 AM
    Monday, January 16, 2012 9:49 PM

Answers

  • Eric,

    First of all you can quickly view the critical path on the Gantt Chart view by going to Format/Bar Styles group and checking the "Critical Tasks" option.

    Bar styles are unique to each view. By default the Gantt Chart view does not have a critical bar style, however the Tracking Gantt view does.

    As far as your recorded macro, the "41" is the item number in the bar styles list for the Gantt Chart view. There are 40 default bar styles for the Gantt Chart view. When you added you custom bar style it became the 41st bar style.

    The best way to find out what Methods, Properties, etc. are available through VBA is via the Object Browser which can be accessed by hitting the Object Browser icon while in the VB Edit window. I couldn't find a BarStyles collection so as far as I can tell there is no way to cycle through all the bar styles and look for one that has the critical parameter.

    Hope this helps.

    John

    • Marked as answer by RunDeep Wednesday, January 18, 2012 8:38 PM
    Tuesday, January 17, 2012 12:00 AM

All replies

  • Eric,

    First of all you can quickly view the critical path on the Gantt Chart view by going to Format/Bar Styles group and checking the "Critical Tasks" option.

    Bar styles are unique to each view. By default the Gantt Chart view does not have a critical bar style, however the Tracking Gantt view does.

    As far as your recorded macro, the "41" is the item number in the bar styles list for the Gantt Chart view. There are 40 default bar styles for the Gantt Chart view. When you added you custom bar style it became the 41st bar style.

    The best way to find out what Methods, Properties, etc. are available through VBA is via the Object Browser which can be accessed by hitting the Object Browser icon while in the VB Edit window. I couldn't find a BarStyles collection so as far as I can tell there is no way to cycle through all the bar styles and look for one that has the critical parameter.

    Hope this helps.

    John

    • Marked as answer by RunDeep Wednesday, January 18, 2012 8:38 PM
    Tuesday, January 17, 2012 12:00 AM
  • Hi John,

    Hadn't noticed the checkbox, makes my immediate problem go away.  I looked through the browser/help pretty thoroughly and didn't see anything either but sometimes I miss things...  Thought application.BarBoxStyles might do it but it just pops up the Bar Styles dialog.

    Thanks,
    Eric

    Tuesday, January 17, 2012 1:09 AM