title: Change one theme/accent color to another accent color for all shapes in a PPT file
body: <p>I have created this code to replace one accent colors of the template with another (ObjectThemeColors), the Brightness (tint and shade) element is over-ruled and all shades of the old accent colors are replaced with the same shade as that of the given new color, can anybody help to preserve the brightness/shades while changing to new accent colors?</p>
  
  <p><a href="https://i.stack.imgur.com/D9Neb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D9Neb.png" alt="Form Screenshot"></a></p>
  
  <pre><code>Sub ReplaceColorNew(OldColor As String, NewColor As String)
  
  Dim oeff As Effect
  Dim i As Integer
  Dim t As Integer
  Dim oSld As Slide
  Dim oShp As Shape
  Dim x, y As Integer
  Dim oPP As Placeholders
  
  For Each oSld In ActivePresentation.Slides
      For Each oShp In oSld.Shapes
      'groups
          If oShp.Type = msoGroup Then
              For x = 1 To oShp.GroupItems.Count
                  With oShp.GroupItems(x)
                      If .Fill.ForeColor.ObjectThemeColor = Conversion.CLng(OldColor) + 5 Then
                         .Fill.ForeColor.ObjectThemeColor = Conversion.CLng(NewColor) + 5
                      End If
  
                      If .Line.Visible Then
                          If .Line.ForeColor.ObjectThemeColor = Conversion.CLng(OldColor) + 5 Then
                             .Line.ForeColor.ObjectThemeColor = Conversion.CLng(NewColor) + 5
                          End If
                      End If
  
                      If .HasTextFrame Then
                          If .TextFrame.HasText Then
                              For y = 1 To .TextFrame.TextRange.Runs.Count
                                  If .TextFrame.TextRange.Runs(y).Font.Color.ObjectThemeColor = Conversion.CLng(OldColor) + 5 Then
                                     .TextFrame.TextRange.Runs(y).Font.Color.ObjectThemeColor = Conversion.CLng(NewColor) + 5
                                  End If
                              Next
                          End If
                      End If
                  End With
              Next
          Else
              With oShp 'other shapes
              ' Fill
                  If .Fill.ForeColor.ObjectThemeColor = Conversion.CLng(OldColor) + 5 Then
                      .Fill.ForeColor.ObjectThemeColor = Conversion.CLng(NewColor) + 5
                  End If
  
                  ' Line
                  If Not .Type = msoTable Then
                      If .Line.Visible = msoTrue Then
                          If .Line.ForeColor.ObjectThemeColor = Conversion.CLng(OldColor) + 5 Then
                              .Line.ForeColor.ObjectThemeColor = Conversion.CLng(NewColor) + 5
                          End If
                      End If
                  End If
  
                  ' Text
                  If .HasTextFrame Then
                      If .TextFrame.HasText Then
                          For y = 1 To .TextFrame.TextRange.Runs.Count
                              If .TextFrame.TextRange.Runs(y).Font.Color.ObjectThemeColor = Conversion.CLng(OldColor) + 5 Then
                                  .TextFrame.TextRange.Runs(y).Font.Color.ObjectThemeColor = Conversion.CLng(NewColor) + 5
                              End If
                          Next
                      End If
                  End If
              End With
          End If
  'oShp = Nothing
      Next oShp
  Next oSld
  
  
  End Sub
  </code></pre>