0

I am working to take slides from various teams and processes and standardize the formatting in PowerPoint 2010. The biggest challenge I am having is cycling through all of the series on a chart, which could be a varying number across slides and from reporting cycle to reporting cycle, and assigning a template color to each.

I have searched through multiple sites for an answer, but have had trouble finding a non-Excel example and something that can dynamically apply colors depending on the number of series in the chart.

My VBA code is below. It successfully cycles through the slides and the shapes on each slide until it finds a chart. Once it detects a chart I am attempting to assign the color and get Run-time error '13': Type mismatch on the ForeColor line. The making the line invisible and then visible again was from another example I saw that the responder said was necessary to make the rest of the formatting work.

Sub Chart_Format()
    Dim Sl As Object
    Dim Sh As Object
    Dim Sr As Series
    For Each Sl In ActivePresentation.Slides
        For Each Sh In Sl.Shapes
            Debug.Print Sl.SlideNumber
            If Sh.HasChart Then
                Debug.Print Sh.Chart.ChartType
                If Sh.Chart.ChartType = 4 Then
                    Sh.Chart.SeriesCollection(1).Format.Line _
                        .Visible = msoFalse
                    Sh.Chart.SeriesCollection(1).Format.Line _
                        .Visible = msoTrue
                    Sh.Chart.SeriesCollection(1).Format.Line _
                        .ForeColor = RGB(1, 1, 1)
                End If
            End If
        Next Sh
    Next Sl
End Sub

Thanks in advance, Eric

ashleedawg
  • 20,365
  • 9
  • 72
  • 105
  • 2
    If by another example you mean [this answer](https://stackoverflow.com/a/29677720/9245853), note that you are missing the `.RGB` on the end of `ForeColor`. – BigBen Aug 28 '18 at 00:54
  • Possible duplicate of [Excel VBA Line Color / Marker Line Color](https://stackoverflow.com/questions/29675485/excel-vba-line-color-marker-line-color) – ashleedawg Aug 28 '18 at 01:21

0 Answers0