Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
254 views
in Technique[技术] by (71.8m points)

vba - Colour coding agile task boxes based on priority level

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

question from:https://stackoverflow.com/questions/66062239/colour-coding-agile-task-boxes-based-on-priority-level

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...