Changing Colors of Task Names

J

Joe

Does anyone know a way to change the color of the task
name based on a test of a flag field?

As an example if the flag field had either 1,2 or 3
assigned to it....Is there a way to print 1's in red, 2's
in blue etc.? I realize the bar on the gantt can be
changed but I would like to change the color of the task
name to further highlight tasks that are critical in
nature.
 
M

Mark Durrenberger

Try this...
Mark

Option Explicit
Sub Macro1()
Dim Activity As Task
Dim TheProject As Tasks
Set TheProject = ActiveProject.Tasks


For Each Activity In TheProject
SelectTaskColumn Column:="Name" ' put active cell in the right column
If Not (Activity Is Nothing) Then ' verify task exists
If Not Activity.ExternalTask Then ' ignore external tasks
If Not Activity.Summary Then ' Ignore summary tasks
If Activity.Critical = True Then ' True so make it red
SelectCell Row:=Activity.ID
Font Color:=pjRed
Else ' false so make it black
SelectCell Row:=Activity.ID
Font Color:=pjBlack
End If ' critical task
End If ' summary task
End If ' external task
End If ' task is nothing

Next Activity

End Sub




--
_________________________________________________________
Mark Durrenberger, PMP
Principal, Oak Associates, Inc, www.oakinc.com
"Advancing the Theory and Practice of Project Management"
________________________________________________________

The nicest thing about NOT planning is
that failure comes as a complete surprise and is not
preceded by a period of worry and depression.

- Sir John Harvey-Jones
 
J

Joe

Mark

Thank you....it worked great!

-----Original Message-----
Try this...
Mark

Option Explicit
Sub Macro1()
Dim Activity As Task
Dim TheProject As Tasks
Set TheProject = ActiveProject.Tasks


For Each Activity In TheProject
SelectTaskColumn Column:="Name" ' put active cell in the right column
If Not (Activity Is Nothing) Then ' verify task exists
If Not Activity.ExternalTask Then ' ignore external tasks
If Not Activity.Summary Then ' Ignore summary tasks
If Activity.Critical = True Then ' True so make it red
SelectCell Row:=Activity.ID
Font Color:=pjRed
Else ' false so make it black
SelectCell Row:=Activity.ID
Font Color:=pjBlack
End If ' critical task
End If ' summary task
End If ' external task
End If ' task is nothing

Next Activity

End Sub




--
_________________________________________________________
Mark Durrenberger, PMP
Principal, Oak Associates, Inc, www.oakinc.com
"Advancing the Theory and Practice of Project Management"
________________________________________________________

The nicest thing about NOT planning is
that failure comes as a complete surprise and is not
preceded by a period of worry and depression.

- Sir John Harvey-Jones



.
 

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