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
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