Hi,
I'm trying to automatically chart a scatter graph in PowerPoint using a dataholder in Excel (i.e. a template where the user enters the data for the chart).
I then need to add data labels to each series collection - so instead of each data point showing the Y axis score or 'Series 1' it shows the name of the data point - i.e. 'Monday', 'Tuesday', etc.
The SeriesCollection property doesn't seem to work in PowerPoint...and I'm at a lost.
Here is my current code - note that the SetSourceData doesn't set the right data columns and I have to go in and press 'Switch Columns' to get it to chart properly.
Any help would be very greatly appreciated! I'm at a complete lost here...
Thanks!
I'm trying to automatically chart a scatter graph in PowerPoint using a dataholder in Excel (i.e. a template where the user enters the data for the chart).
I then need to add data labels to each series collection - so instead of each data point showing the Y axis score or 'Series 1' it shows the name of the data point - i.e. 'Monday', 'Tuesday', etc.
The SeriesCollection property doesn't seem to work in PowerPoint...and I'm at a lost.
Here is my current code - note that the SetSourceData doesn't set the right data columns and I have to go in and press 'Switch Columns' to get it to chart properly.
Code:
Sub CreateAutomatedChart()
'********************
'* SETUP *
'********************
Dim xlApp As Object 'Sets Excel as Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Dim xlWks As Object 'Set Excel dataholder as Object
file = ActivePresentation.Path & "\Automated Charts - Service Area Awareness Summary.xlsx"
Set xlWks = xlApp.Workbooks.Open(file)
'********************
'* UPDATE CHART *
'********************
Set scatterChart = ActivePresentation.Slides(1).Shapes(2).Chart
scatterChart.ChartData.Activate
For x = 2 To 32
scatterChart.ChartData.Workbook.Sheets(1).Cells(x, 1).Value = _
xlWks.Sheets(1).Cells(x, 2) 'X Axis
scatterChart.ChartData.Workbook.Sheets(1).Cells(x, 2).Value = _
Format(xlWks.Sheets(1).Cells(x, 3), "0") 'Y Axis
scatterChart.ChartData.Workbook.Sheets(1).Cells(x, 3).Value = _
xlWks.Sheets(1).Cells(x, 1) 'Labels
Next x
scatterChart.SetSourceData ("Sheet1!$A$2:$B$" & x)
scatterChart.ChartData.Workbook.Close
FileName = "Service Area Awareness Summary - " & Format(Date, "yy mm dd")
ActivePresentation.SaveAs FileName:=ActivePresentation.Path & "\" & FileName
End Sub
Any help would be very greatly appreciated! I'm at a complete lost here...
Thanks!