Hi Team,
I have a worksheet with mutliple charts and excel widgets. I have to paste each grouped chart into a powerpoint silde. I will be able to copy each chart or each shape individually to powerpoint using VBA. However I m struggling to copy and paste the grouped charts and shapes into powerpoint. below is the code i have used.
Please help me on this.
Option Explicit
Sub exportcharts()
Dim ppapp As PowerPoint.Application
Dim ppres As PowerPoint.Presentation
Set ppapp = New PowerPoint.Application
ppapp.Visible = msoTrue
Set ppres = ppapp.Presentations.Open(Application.GetOpenFilename(), , False)
Dim ppress As PowerPoint.Presentation
Set ppress = ppapp.ActivePresentation
Dim pslide As PowerPoint.Slide
Dim total_slide As Long
total_slide = ppres.Slides.Count
Dim ws As Worksheet
Dim cht As ChartObject
Dim i As Long
i = 2
For Each ws In Worksheets
For Each cht In ws.ChartObjects
cht.Copy
ppres.Slides(i).Shapes.PasteSpecial (ppPasteEnhancedMetafile)
i = i + 1
Next
Next
End Sub
I have a worksheet with mutliple charts and excel widgets. I have to paste each grouped chart into a powerpoint silde. I will be able to copy each chart or each shape individually to powerpoint using VBA. However I m struggling to copy and paste the grouped charts and shapes into powerpoint. below is the code i have used.
Please help me on this.
Option Explicit
Sub exportcharts()
Dim ppapp As PowerPoint.Application
Dim ppres As PowerPoint.Presentation
Set ppapp = New PowerPoint.Application
ppapp.Visible = msoTrue
Set ppres = ppapp.Presentations.Open(Application.GetOpenFilename(), , False)
Dim ppress As PowerPoint.Presentation
Set ppress = ppapp.ActivePresentation
Dim pslide As PowerPoint.Slide
Dim total_slide As Long
total_slide = ppres.Slides.Count
Dim ws As Worksheet
Dim cht As ChartObject
Dim i As Long
i = 2
For Each ws In Worksheets
For Each cht In ws.ChartObjects
cht.Copy
ppres.Slides(i).Shapes.PasteSpecial (ppPasteEnhancedMetafile)
i = i + 1
Next
Next
End Sub