-1

This code is not working, i want change colar and format with this code. What is wong.

Sub asdf1()
Dim msTask As Task
For Each msTask In ActiveProject.Tasks
    If msTask.Summary = True Then
       GanttBarFormat GanttStyle:=5, TaskID:=msTask.ID, _
       MiddleColor:=pjYellow, StartColor:=pjGreen, _
       EndColor:=pjGreen, ProjectName:=msTask.Project
   Else
       GanttBarFormat GanttStyle:=5, TaskID:=msTask.ID, _
       MiddleColor:=pjRed, StartColor:=pjGreen, _
       EndColor:=pjGreen, ProjectName:=msTask.Project
    End If
Next
End Sub
braX
  • 11,506
  • 5
  • 20
  • 33
Pedro6840
  • 9
  • 2

1 Answers1

0

Pedro6840, You're code works fine. I suspect you have not correctly identified the 'GanttStyle' argument. Both options in the "if" statement are set to edit the 5th row in the Bar Styles list. With default settings, the 5th row is the Project Summary task Gantt Bar but if you have edited your bar styles list, that row may be something else.

I suggest you review your Bar Styles list (Gantt Chart Format > Bar Styles > Format > Bar Styles) to insure you have correctly identified the bar style associated with the row number in the list.

One other point, your code customizes the Gnatt Bar of a specific task ID. It does NOT modify the global bar styles (e.g. all other summary lines) John

john-project
  • 331
  • 1
  • 7