Hi
this macro exports all charts in the active workbook to a new powerpoint presentation.
you may want to adjust the shape width and layout depending on your presentation type.
note that to run this you must have the powerpoint object library checked under tools > reference in the vba area.
Sub charts_export_to_powerpoint()
'copies pictures of all charts in the workbook into a new pp presentation
'ensure microsoft powerpoint object library is checked in tools references
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim ch As ChartObject, chr As Chart, n, ws, sN, z, ts
ts = ActiveSheet.Name
sN = 1
Set PPApp = CreateObject("Powerpoint.Application")
PPApp.Visible = True
Set PPPres = PPApp.Presentations.Add
PPPres.PageSetup.SlideSize = 1
For n = 1 To ActiveWorkbook.Sheets.Count
'charts embedded in worksheets
If Sheets(n).Type = 4 Then
Sheets(n).Select
ActiveChart.Deselect
ActiveChart.CopyPicture
PPPres.Slides.Add sN, ppLayoutBlank
PPPres.Slides(sN).Shapes.Paste
PPPres.Slides(sN).Shapes(1).Width = 640
PPPres.Slides(sN).Shapes.Range.Align msoAlignCenters, True
PPPres.Slides(sN).Shapes.Range.Align msoAlignMiddles, True
sN = 1 + sN
Else
'charts in chart sheets
If Sheets(n).ChartObjects.Count > 0 Then
Sheets(n).Select
For z = 1 To Sheets(n).ChartObjects.Count
Sheets(n).ChartObjects(z).CopyPicture
PPPres.Slides.Add sN, ppLayoutBlank
PPPres.Slides(sN).Shapes.Paste
PPPres.Slides(sN).Shapes(1).Width = 640
PPPres.Slides(sN).Shapes.Range.Align msoAlignCenters, True
PPPres.Slides(sN).Shapes.Range.Align msoAlignMiddles, True
sN = 1 + sN
Next z
End If
End If
Next n
Sheets(ts).Select
PPApp.WindowState = ppWindowMaximized
Set PPPres = Nothing
Set PPApp = Nothing
End Sub
Bookmarks