Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Graph - Line Series Color

Status
Not open for further replies.

SkipVought

Programmer
Dec 4, 2001
47,492
US
VB Help is scant on this.

I am trying to manipulate the Series Interior Color on MS Graphs in a Power Point application for Pie, Bar and Line charts. (see thread707-612936)

On the Line Chart Series I get an error on assigning the interior color. I can set Marker Back/Fore colors. What magic can I conger from my fellow VBA wizards.

Here's my code so far...
Code:
Sub atest()
    Dim sl As Slide, sh As Shape, ch As Chart, s As Series, p As Point
    For Each sl In ActivePresentation.Slides
        For Each sh In sl.Shapes
            If sh.Type = msoEmbeddedOLEObject Then
                i = 1
                Set ch = sh.OLEFormat.Object
                Select Case ch.ChartType
                    Case xl3DPie
                        For Each s In ch.SeriesCollection
                            j = 1
                            For Each p In s.Points
                                Select Case j
                                    Case 1
                                        p.Interior.Color = RGB(0, 0, 255)
                                    Case 2
                                        p.Interior.Color = RGB(0, 255, 0)
                                    Case 3
                                        p.Interior.Color = RGB(255, 0, 0)
                                End Select
                                j = j + 1
                            Next
                            i = i + 1
                        Next
                    Case xl3DBarClustered
                        For Each s In ch.SeriesCollection
                            Select Case i
                                Case 1
                                    s.Interior.Color = RGB(0, 34, 76)
                                Case 2
                                    s.Interior.Color = RGB(174, 188, 158)
                                Case 3
                                    s.Interior.Color = RGB(111, 150, 201)
                            End Select
                            i = i + 1
                        Next
                    Case xlLineMarkers
                        For Each s In ch.SeriesCollection
                            Select Case i
                                Case 1
                                    s.Fill.Color = RGB(0, 34, 76)
                                Case 2
                                    s.Interior.Color = RGB(174, 188, 158)
                                Case 3
                                    s.MarkerBackgroundColor = RGB(111, 150, 201)
                            End Select
                            i = i + 1
                        Next
                End Select
            End If
        Next
    Next
    Set ch = Nothing
End Sub


Skip,
Skip@TheOfficeExperts.com
 
Hi Skip,

I'm going to post in the other thread about the colours, but as you've started this thread for this specific issue I'll post here as well.

I had a play with it, and this is trial and error to some extent, as VBA Help is rather light on information, but ..

I don't think a Line has an Interior, it has a Border, and setting s.Border.Color seems to work OK.

Enjoy,
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top