The use of custom color coding for bars, text & background in Gantt Chart view is quite common in my company.
Unfortunately, most people use the manual option (change bar code) which wastes time and limits the formatting options of a Gantt Chart.
The use of flags is a valid option, however, it is still too confusing for most people.
In order to make it simpler, I developed a set of scripts that change the colors of bars, text & background in a table depending on value of customised field text(30).
By putting the described color in drop down list in text(30), a user can choose from 16 colors offered in MS Project 2007.
I developed the following codes:
- to reset all color formatting (bars, texts, background);
- to format bar color;
- to format text color in a table;
- to format background color in a table;
The code doesn't seem to work smoothly on larger files.
It doesn't work in the background and as a result it's a bit sluggish.
Is there a way of improving it?
Can someone test it, please?
Sub Text30_Change_All()
Dim tskT As Tasks
Dim t As Task
Set tskT = ActiveProject.Tasks
For Each t In tskT
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjBlack, Bold:=True
FontEx CellColor:=pjWhite, Reset:=True
Select Case t.Text30
Case ""
GanttBarFormat TaskID:=t.ID, Reset:=True
GanttBarFormat TaskID:=t.ID, MiddleColor:=pjBlue, StartColor:=pjBlue, EndColor:=pjBlue
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjWhite, Bold:=True
FontEx CellColor:=pjWhite, Reset:=True
Case "blue"
GanttBarFormat TaskID:=t.ID, Reset:=True
GanttBarFormat TaskID:=t.ID, MiddleColor:=pjBlue, StartColor:=pjBlue, EndColor:=pjBlue
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjWhite, Bold:=True
FontEx CellColor:=pjBlue
Case "black"
GanttBarFormat TaskID:=t.ID, Reset:=True
GanttBarFormat TaskID:=t.ID, MiddleColor:=pjBlack, StartColor:=pjBlack, EndColor:=pjBlack
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjWhite, Bold:=True
FontEx CellColor:=pjBlack
Case "yellow"
GanttBarFormat TaskID:=t.ID, Reset:=True
GanttBarFormat TaskID:=t.ID, MiddleColor:=pjYellow, StartColor:=pjYellow, EndColor:=pjYellow
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjNavy, Bold:=True
FontEx CellColor:=pjYellow
Case "lime"
GanttBarFormat TaskID:=t.ID, Reset:=True
GanttBarFormat TaskID:=t.ID, MiddleColor:=pjLime, StartColor:=pjLime, EndColor:=pjLime
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjNavy, Bold:=True
FontEx CellColor:=pjLime
Case "aqua"
GanttBarFormat TaskID:=t.ID, Reset:=True
GanttBarFormat TaskID:=t.ID, MiddleColor:=pjAqua, StartColor:=pjAqua, EndColor:=pjAqua
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjNavy, Bold:=True
FontEx CellColor:=pjAqua
Case "fuchsia"
GanttBarFormat TaskID:=t.ID, Reset:=True
GanttBarFormat TaskID:=t.ID, MiddleColor:=pjFuchsia, StartColor:=pjFuchsia, EndColor:=pjFuchsia
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjNavy, Bold:=True
FontEx CellColor:=pjFuchsia
Case "white"
GanttBarFormat TaskID:=t.ID, Reset:=True
GanttBarFormat TaskID:=t.ID, MiddleColor:=pjWhite, StartColor:=pjWhite, EndColor:=pjWhite
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjBlack, Bold:=True
FontEx CellColor:=pjWhite
Case "olive"
GanttBarFormat TaskID:=t.ID, Reset:=True
GanttBarFormat TaskID:=t.ID, MiddleColor:=pjOlive, StartColor:=pjOlive, EndColor:=pjOlive
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjWhite, Bold:=True
FontEx CellColor:=pjOlive
Case "navy"
GanttBarFormat TaskID:=t.ID, Reset:=True
GanttBarFormat TaskID:=t.ID, MiddleColor:=pjNavy, StartColor:=pjNavy, EndColor:=pjNavy
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjWhite, Bold:=True
FontEx CellColor:=pjNavy
Case "purple"
GanttBarFormat TaskID:=t.ID, Reset:=True
GanttBarFormat TaskID:=t.ID, MiddleColor:=pjPurple, StartColor:=pjPurple, EndColor:=pjPurple
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjWhite, Bold:=True
FontEx CellColor:=pjPurple
Case "teal"
GanttBarFormat TaskID:=t.ID, Reset:=True
GanttBarFormat TaskID:=t.ID, MiddleColor:=pjTeal, StartColor:=pjTeal, EndColor:=pjTeal
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjWhite, Bold:=True
FontEx CellColor:=pjTeal
Case "silver"
GanttBarFormat TaskID:=t.ID, Reset:=True
GanttBarFormat TaskID:=t.ID, MiddleColor:=pjSilver, StartColor:=pjSilver, EndColor:=pjSilver
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjBlack, Bold:=True
FontEx CellColor:=pjSilver
Case "green"
GanttBarFormat TaskID:=t.ID, Reset:=True
GanttBarFormat TaskID:=t.ID, MiddleColor:=pjGreen, StartColor:=pjGreen, EndColor:=pjGreen
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjWhite, Bold:=True
FontEx CellColor:=pjGreen
Case "gray"
GanttBarFormat TaskID:=t.ID, Reset:=True
GanttBarFormat TaskID:=t.ID, MiddleColor:=pjGray, StartColor:=pjGray, EndColor:=pjGray
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjBlack, Bold:=True
FontEx CellColor:=pjGray
Case "red"
GanttBarFormat TaskID:=t.ID, Reset:=True
GanttBarFormat TaskID:=t.ID, MiddleColor:=pjRed, StartColor:=pjRed, EndColor:=pjRed
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjWhite, Bold:=True
FontEx CellColor:=pjRed
Case "maroon"
GanttBarFormat TaskID:=t.ID, Reset:=True
GanttBarFormat TaskID:=t.ID, MiddleColor:=pjMaroon, StartColor:=pjMaroon, EndColor:=pjMaroon
SelectRow t.UniqueID, RowRelative:=False
Font Color:=pjWhite, Bold:=True
FontEx CellColor:=pjMaroon
Case Else
End Select
Next t
End Sub