Get data from embedded Excel chart

Techbert

New Member
Joined
Dec 11, 2014
Messages
2
Hello Everyone,

Great to be able to finally post to this much used resource.

The issue at hand, I receive PowerPoint files with several embedded Excel charts, with no access to the source data. My task is to extract data from specific charts and compile it into a comparative Excel table. While I am able to get the series data points and compiling the data after retrieval is not an issue, my challenge has been to get the horizontal axis data point labels.

Sample Chart

Garbled image removed by Moderator

Sample Code

Sub test()

Dim sld As Slide
Dim shp As Shape
Dim valarray As Variant
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.HasChart Then
If shp.Chart.ChartType = 51 And InStr(LCase(shp.Chart.ChartTitle.Text), "mom") > 0 Then
Debug.Print sld.SlideNumber
Debug.Print shp.Chart.ChartTitle.Text & ": " & shp.Chart.ChartType
valarray = shp.Chart.SeriesCollection(2).Values
Debug.Print shp.Chart.SeriesCollection(2).Name
For i = 1 To UBound(valarray)
Debug.Print Round(valarray(i), 4)
Next i
End If

End If
Next shp
Debug.Print
Next sld
End Sub

The code does return the expected chart title and the second series (November) title and values. I have tried various iterations of Chart.SeriesCollection and Chart.Axes code as collections, but not been able to pull the location labels.

Any assistance would be appreciate.
 
Last edited by a moderator:

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi
Welcome to the board

As you may know this is an excel not a ppt forum.

This code works for me when executed from excel.

See if this helps:

Code:
Sub PPTChartTest()
Dim pptApp As PowerPoint.Application
Dim pptPre As PowerPoint.Presentation
Dim pptSld As PowerPoint.Slide
Dim pptShp As PowerPoint.Shape
Dim pptCht As PowerPoint.Chart
Dim pptXAxisCategoryNames As Variant
Dim sFile As String
Dim vYValues As Variant
    
    sFile = "c:\tmp\pptchart1.pptx"

    Set pptApp = New PowerPoint.Application
    Set pptPre = pptApp.Presentations.Open(Filename:=sFile, ReadOnly:=msoFalse)

    For Each pptSld In pptPre.Slides
        For Each pptShp In pptSld.Shapes
            If pptShp.HasChart Then
                Set pptCht = pptShp.Chart
                If pptCht.ChartType = 51 And pptCht.HasTitle Then
                    If InStr(LCase(pptCht.ChartTitle.Text), "mom") > 0 Then
                        vYValues = pptCht.SeriesCollection(2).Values
                        pptXAxisCategoryNames = pptCht.Axes(Type:=xlCategory).CategoryNames
                        
                        ' debug messages
                        Debug.Print "Slide number: " & pptSld.SlideNumber
                        Debug.Print "Chart title - type: " & pptCht.ChartTitle.Text & " - " & pptCht.ChartType
                        Debug.Print "Series 2 name: " & pptCht.SeriesCollection(2).Name
                        Debug.Print "Series 2 Y values: " & Join(vYValues)
                        Debug.Print "X axis categories: " & Join(pptXAxisCategoryNames)
                        
                    End If
                End If
            End If
        Next pptShp
    Next pptSld
    
    pptPre.Close
    pptApp.Quit
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

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