VBA Macro for MS Project (Color Coded WBS)

Anonymous
2022-12-13T12:33:13+00:00

Hi,

Can someone help me with a code for color my WBS Font in MS Project similar to Primavera P6?

WBS Level 0-10

Regards

Fredrik

Microsoft 365 and Office | Project | For education | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. John Project 49,695 Reputation points Volunteer Moderator
    2023-01-06T16:13:20+00:00

    Fredrik,

    Here's the updated macro and what it produces.

    Sub HighlightSummaries_P6()
    'Summary line color emulation P6 > Project
    'macro written by John-Project 12/21/22
    ' Changed color sequence so first summary level is Project Summary Task 1/4/23
    Dim i As Integer
    ActiveProject.DisplayProjectSummaryTask = True
    SelectAll
    EditClearFormats
    'set colors for Project Summary Task
    SelectRow Row:=0
    Font32Ex Color:=16777215, CellColor:=11892014 'R46.G117,B181
    'Set colors for summary levels
    For i = 1 To 19
    FilterEdit Name:="OLX", Taskfilter:=True, create:=True, overwriteexisting:=True, _
    FieldName:="summary", test:="equals", Value:="yes", ShowInMenu:=False
    FilterEdit Name:="OLX", Taskfilter:=True, Operation:="and", _
    NewFieldName:="outline level", test:="equals", Value:=CStr(i)
    FilterApply Name:="OLX"
    SelectAll
    If ActiveSelection > 0 Then
    'Note: Font32EX does not work with hex values
    If i = 1 Then Font32Ex CellColor:=14062212 'R132,B146,B214
    If i = 2 Then Font32Ex CellColor:=16354179 'R131,G139,B249
    If i = 3 Then Font32Ex CellColor:=16776960 'R0,G255,B255
    If i = 4 Then Font32Ex CellColor:=15058378 'R202.G197,B229
    If i = 5 Then Font32Ex CellColor:=16119719 'R167,G247,B245
    If i = 6 Then Font32Ex CellColor:=15048173 'R237,G157,B229
    If i = 7 Then Font32Ex CellColor:=10223101 'R253,G253,B155
    If i = 8 Then Font32Ex Color:=16777215, CellColor:=0 'R0,G0,B0
    If i = 9 Then Font32Ex CellColor:=14211288 'R216,G216,B216
    If i = 10 Then Font32Ex CellColor:=4690227 'R51,G145,B71
    If i = 11 Then Font32Ex Color:=16777215, CellColor:=16260866 'R22,G22,B250
    If i = 12 Then Font32Ex Color:=16777215, CellColor:=3497611 'R127,G84,B49
    If i = 13 Then Font32Ex Color:=16777215, CellColor:=10027161 'R153,G0,B153
    If i = 14 Then Font32Ex Color:=16777215, CellColor:=39423 'R255,G153,B0
    If i = 15 Then Font32Ex Color:=16777215, CellColor:=12033691 'R163,G163,B193
    If i = 16 Then Font32Ex Color:=16777215, CellColor:=42152 'R168,G164,B0
    If i = 17 Then Font32Ex Color:=16777215, CellColor:=9211036 'R156,G140,B140
    If i = 18 Then Font32Ex Color:=16777215, CellColor:=8689730 'R66,G153,B132
    If i = 19 Then Font32Ex Color:=16777215, CellColor:=11701388 'R140,G140,B178
    Else
    Exit For
    End If
    Next i
    FilterApply Name:="all tasks"
    End Sub

    John

    5 people found this answer helpful.
    0 comments No comments

22 additional answers

Sort by: Most helpful
  1. John Project 49,695 Reputation points Volunteer Moderator
    2022-12-13T18:41:26+00:00

    Hedin Fredrik,

    This is a forum for MS Project so I have no idea what the Primavera P6 font format looks like. If you can show a screen shot with more details on what you want perhaps we can help.

    You mention helping you with VBA code, do you already have a macro or are you looking for us to write one for you?

    John

    0 comments No comments
  2. Anonymous
    2022-12-13T19:31:00+00:00

    Hi John,

    I think you helped a guy last year with the same question. see link. I would like the same code/macro but from Level 0-10

    VBA-makro för MS Project (färgkodad WBS) - Microsoft Community

    Regards

    Fredrik

    1 person found this answer helpful.
    0 comments No comments
  3. Anonymous
    2022-12-13T19:41:18+00:00

    So the project name also i coloured

    //Fredrik

    0 comments No comments
  4. John Project 49,695 Reputation points Volunteer Moderator
    2022-12-13T22:02:21+00:00

    Fredrik,

    Yes, your question did sound familiar. And yes, I wrote that macro to cover level 1 thru 6. You want level 0 thru 10. So what color is level 0 and what colors are levels 7 thru 10 in Primavera P6? A screen shot like the original poster provided would help.

    John

    0 comments No comments