swayp11
05-10-2013, 02:29 PM
I am trying to loop through a presentation that has charts and I would like to grab the data from each chart and paste into Excel.
I think I am doing this right, first I loop through slides, then shapes:
Dim ppSlide As PowerPoint.Slide
Dim ppShape As PowerPoint.Shape
Dim Cht1 As Chart
Dim myChartdata As ChartData
Dim myWkbk As Excel.Workbook
Dim myWksht As Excel.Worksheet
For Each ppSlide In ActivePresentation.Slides
For Each ppShape In ppSlide.Shapes
If ppShape.Type = msoChart Then
MsgBox ("x")
End If
Next
Next
I never get inside the if statement because I assume that the chart is not an object but rather just a chart (for example, Chart 3). How can I get to the underlying Excel sheet of this chart so I can copy the data the chart is referencing?
Then, I am going to try and open a new excel window and paste it all in the first sheet. I'm trying something like this:
Dim newExcel As Excel.Application
Set myWkbk = newExcel.Workbooks.Add
mywkbk.worksheets(1).range("A1").paste
...
Thanks for any tips or points in the right direction!
PowerPoint/Excel 2007
I think I am doing this right, first I loop through slides, then shapes:
Dim ppSlide As PowerPoint.Slide
Dim ppShape As PowerPoint.Shape
Dim Cht1 As Chart
Dim myChartdata As ChartData
Dim myWkbk As Excel.Workbook
Dim myWksht As Excel.Worksheet
For Each ppSlide In ActivePresentation.Slides
For Each ppShape In ppSlide.Shapes
If ppShape.Type = msoChart Then
MsgBox ("x")
End If
Next
Next
I never get inside the if statement because I assume that the chart is not an object but rather just a chart (for example, Chart 3). How can I get to the underlying Excel sheet of this chart so I can copy the data the chart is referencing?
Then, I am going to try and open a new excel window and paste it all in the first sheet. I'm trying something like this:
Dim newExcel As Excel.Application
Set myWkbk = newExcel.Workbooks.Add
mywkbk.worksheets(1).range("A1").paste
...
Thanks for any tips or points in the right direction!
PowerPoint/Excel 2007