Coloring bar graph type

Valgo54

New Member
Joined
Aug 31, 2013
Messages
25
Hello
I am encountering problem in coloring a bar graph chart in a PPT presentation.
I am doing that with excel vba macro 2007. The same code is working with grao bubble and istogram.
Any help will be appreciated.
Thanks

Code:
Private pptApp As PowerPoint.Application
Private xlapp As Excel.Application
Private strPowerpointModelPath As String, oPowerpointModel As Object
Private strPowerpointPresentation As String
Private Opptfile As PowerPoint.Presentation
Private oChartShape As Object
Private ChartSource As Range
Private wschart As Worksheet
Dim col, num_tot_col, ws_input_rows, num_slide, i, l As Integer

 Sub Mod_graf()
    
    Set xlapp = GetObject(, "Excel.Application")
    If Err.Number <> 0 Then
        Err.Clear
        Set xlapp = CreateObject("Excel.Application")
    End If
    
    
    ' apro il file ppt
    Set pptApp = CreateObject("Powerpoint.Application")
    pptApp.Visible = True
    With ThisWorkbook
        strPowerpointPresentation = ThisWorkbook.Path & "\" & "mod_graf_barre_1" & ".pptx"
    End With
    
    Set Opptfile = pptApp.Presentations.Open(Filename:=strPowerpointPresentation, WithWindow:=msoTrue, Untitled:=msoTrue)
    num_slide = 1
       
    ApreChart Opptfile.Slides(num_slide).Shapes("Chart")
        
    ModChart
        
    ChiudeChart
 
    Opptfile.SaveAs (strPowerpointPresentation)
    Opptfile.Close
    Set Opptfile = Nothing
    pptApp.Quit
    MsgBox "Grafici bubble elaborati.", vbInformation
    

End Sub
Sub ModChart()

        oChartShape.Chart.SeriesCollection(1).Points(1).Interior.Color = RGB(0, 255, 0) 'green
        oChartShape.Chart.SeriesCollection(2).Points(1).Interior.Color = RGB(143, 0, 255) 'violet
        oChartShape.Chart.SeriesCollection(3).Points(1).Interior.Color = RGB(255, 255, 51) ' yellow
    
End Sub

Sub ChiudeChart(Optional bParam As Boolean)
    oChartShape.Chart.Refresh
    Set wschart = Nothing
    oChartShape.Chart.ChartData.Workbook.Close
    Set oChartShape = Nothing
End Sub

Sub ApreChart(oChart)
   Set oChartShape = oChart
    oChartShape.Chart.ChartData.Activate

End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hello
I solved with
oChartShape.Chart.SeriesCollection(1).Points(1).Format.Fill.ForeColor.RGB = RGB(0, 0, 255) ' blu color
 
Upvote 0

Forum statistics

Threads
1,223,996
Messages
6,175,864
Members
452,678
Latest member
will_simmo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top