-2

I am new to MS projects and want to format task boxes within a sprint board so that the priority level assigns a color to the box. Is this possible and can anyone write the code for it (I don't know anything about coding)? Edit: I need to clarify, I am wanting to change the color of the sprint task boxes, not in a network diagram format. Apologies for the lack of clarity.

Sprint format

  • Note: this site is for specific programing questions, which this is. (See [What topics can I ask about here?](https://stackoverflow.com/help/on-topic)) However, asking for someone to write the code for you is a quick way to get downvoted because it implies that you did not do any research on your own first. See [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask). – Rachel Hettinger Feb 05 '21 at 17:11

1 Answers1

0

Here is a basic example of how to format the boxes (nodes) in a network diagram view. This code sets the background color of the box based on the task's priority. The BoxFormat method can also format gridlines, border styles, etc.

Sub FormatBoxes()

    ViewApply Name:="Network Diagram"
    
    Dim t As Task
    For Each t In ActiveProject.Tasks
        Select Case t.Priority
            Case Is <= 100
                BoxFormat TaskID:=t.ID, BackgroundColor:=pjFuchsia
            Case Is <= 300
                BoxFormat TaskID:=t.ID, BackgroundColor:=pjBlue
            Case Is <= 500
                BoxFormat TaskID:=t.ID, BackgroundColor:=pjYellow
            Case Else
                BoxFormat TaskID:=t.ID, BackgroundColor:=pjRed
        End Select
    Next t

End Sub
Rachel Hettinger
  • 7,927
  • 2
  • 21
  • 31
  • Hello, I do not want a network diagram, I am using a scrum/kanban format and just want to change the color of the 'cards'. To do this, would I just change the ViewApply Name:=? – Theo Levine Feb 06 '21 at 12:39
  • Yes, if it’s based on the Network Diagram view format, just change the name. If it’s some other format, edit your question to show an image of the view that you want to modify. – Rachel Hettinger Feb 06 '21 at 20:08