whats wrong with this vba code?

M

magda

Hi,
I'm trying to change font colour for name of all tasks which have flag1 set
to Yes (yes it is polish "Tak"), but this work in selected cell only :(
I'm newbe with vba, could someone help me please with following code?

Dim T, Td As Task
For Each T In ActiveProject.Tasks
If Not T Is Nothing Then
If Not T.Summary Then
If T.Flag1 = True Then
For Each Td In ActiveProject.Tasks
FontEx Color:=1
Next Td
End If
End If
End If
Next T

thanks
magda
 
R

Rod Gill

Hi,

From your code I think you want every task with Flag1=True and every subtask
of any summary task with Flag1=true to be Red?

If so the following works:

Sub Test()
Dim T As Task, Td As Task
For Each T In ActiveProject.Tasks
If Not T Is Nothing Then
T.Marked = False
End If
Next

For Each T In ActiveProject.Tasks
If Not T Is Nothing Then
If T.Summary And T.Flag1 = True Then
For Each Td In T.OutlineChildren
Td.Marked = True
Next Td
ElseIf T.Flag1 = True Then
T.Marked = True
End If
End If
Next T
Application.TextStyles Item:=5, Color:=pjRed
End Sub

There is a Text Style called Marked. The final statement sets this style to
red text for any Task with Marked=True.

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 

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