Guild of Project Controls: Compendium | Roles | Assessment | Certifications | Membership

Tips on using this forum..

(1) Explain your problem, don't simply post "This isn't working". What were you doing when you faced the problem? What have you tried to resolve - did you look for a solution using "Search" ? Has it happened just once or several times?

(2) It's also good to get feedback when a solution is found, return to the original post to explain how it was resolved so that more people can also use the results.

MS Project color rolled up taskbar

2 replies [Last post]
Forum Guest
User offline. Last seen 2 years 29 weeks ago. Offline
Joined: 28 Jan 2009
Posts: 1
Groups: None
Hi, does anybody know how you can change the bar color of an individual rolled up task by means of VB?

More specific: Suppose you have two tasks after each other rolled up to a main task. The main task will now show 2 bars on the same line. How can the color of one of these bars be changed? (It can be done manually!)

To change the bar color of a normal task, I use code like this:
activeproject.Tasks.Application.GanttBarFormat(taskid:=4,middlecolor:=pjgreen)

Replies

Renaud Moisan
User offline. Last seen 12 years 48 weeks ago. Offline
Joined: 3 Nov 2005
Posts: 11
Sorry for unearthing this topic :)

Using VBA, I am looking for a way to copy a bar attribute (color, style, ...) to another bar.

Searching the web I found how to assign a format to a bar using ganttbarformat. But I cannot find a way to get the format values of a given bar... Anybody can help?
Forum Guest
User offline. Last seen 2 years 29 weeks ago. Offline
Joined: 28 Jan 2009
Posts: 1
Groups: None
(solution provided by GĂ©rard Ducouret)

Refer to the subtask with this code:

GanttBarFormat TaskId:=x,GanttStyle:=y, MiddleColor:=z

x=TaskID
y=style number of the rolled up bar (see bar styles: default = 5)
z=predefined color (e.g. pjGreen)