DougTrajano
09-25-2017, 04:57 AM
Hi guys.
I posted a question in Excel Help and problem was fixed. My problem now is how I can adapt this macro to PowerPoint.
I attached my excel in this thread. 20456
I need create a PowerPoint file with this graphs and I would like use this macro in PowerPoint to set up colors of series graphs.
I really appreciate your help.
Tks
Paul_Hossler
09-25-2017, 08:13 AM
Not very elegant and could use some error checking
Option Explicit
Sub ApplyColors()
Dim oSlide As Slide
Dim oShape As Shape
Dim oChart As Chart
Dim oSeries As Series
Dim v As Variant
Dim iSeries As Long
For Each oSlide In ActivePresentation.Slides
For Each oShape In oSlide.Shapes
Set oChart = Nothing
On Error Resume Next
Set oChart = oShape.Chart
On Error GoTo 0
If Not oChart Is Nothing Then
For iSeries = 1 To oChart.SeriesCollection.Count
v = Split(oChart.SeriesCollection(iSeries).Name, " ")
oChart.SeriesCollection(iSeries).Interior.Color = Name2Color(CStr(v(0)))
Next iSeries
End If
Next
Next
End Sub
Function Name2Color(s As String) As Long
Select Case s
Case "Bárbara": Name2Color = RGB(102, 0, 102)
Case "Bruna": Name2Color = RGB(49, 133, 156)
Case "Cassiano": Name2Color = RGB(55, 96, 146)
Case "Daniele": Name2Color = RGB(0, 0, 0)
Case "Fabio": Name2Color = RGB(255, 235, 158)
Case "Fernando": Name2Color = RGB(255, 255, 0)
Case "Guilherme": Name2Color = RGB(127, 127, 127)
Case "Gustavo": Name2Color = RGB(155, 187, 89)
Case "Henrique": Name2Color = RGB(204, 193, 218)
Case "Jorge": Name2Color = RGB(33, 89, 104)
Case "Julio": Name2Color = RGB(195, 214, 155)
Case "Leandro": Name2Color = RGB(64, 49, 82)
Case "Lucas": Name2Color = RGB(119, 147, 60)
Case "Luiza": Name2Color = RGB(123, 123, 123)
Case "Pedro": Name2Color = RGB(1, 13, 255)
Case "Priscilla": Name2Color = RGB(204, 51, 0)
Case "Sergio": Name2Color = RGB(152, 72, 7)
End Select
End Function
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.