J
jamesTcarville
Hi everybody,
I have created an Excel file with multiple charts, each of them is on a
single sheet. I'm trying to create a macro to copy each slide, paste it
on a powerpoint slide, get to the next sheet, to copy the slide, paste
it on the next powerpoint slide, and so on till the end.
Here's the code. I'm stuck when I try to copy the chart.
Does anyone know a simple way to achieve that ?
Thanks
Sub GraphPowerpoint()
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim PresentationFileName As Variant
Dim SlideCount As Long
Dim iCht As Integer
Set PPApp = CreateObject("Powerpoint.Application")
PPApp.Visible = True
Set PPPres = PPApp.Presentations.Add(msoTrue)
Set PPSlide = PPPres.Slides.Add(1, ppLayoutBlank)
PPApp.ActiveWindow.ViewType = ppViewSlide
For Each f In Worksheets
Sheets(f.Name).Activate
ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen,
Format:=xlPicture
SlideCount = PPPres.Slides.Count
Set PPSlide = PPPres.Slides.Add(SlideCount + 1, ppLayoutBlank)
With PPSlide
.Shapes.Paste
End With
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
SlideCount = SlideCount + 1
Next
End Sub
I have created an Excel file with multiple charts, each of them is on a
single sheet. I'm trying to create a macro to copy each slide, paste it
on a powerpoint slide, get to the next sheet, to copy the slide, paste
it on the next powerpoint slide, and so on till the end.
Here's the code. I'm stuck when I try to copy the chart.
Does anyone know a simple way to achieve that ?
Thanks
Sub GraphPowerpoint()
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim PresentationFileName As Variant
Dim SlideCount As Long
Dim iCht As Integer
Set PPApp = CreateObject("Powerpoint.Application")
PPApp.Visible = True
Set PPPres = PPApp.Presentations.Add(msoTrue)
Set PPSlide = PPPres.Slides.Add(1, ppLayoutBlank)
PPApp.ActiveWindow.ViewType = ppViewSlide
For Each f In Worksheets
Sheets(f.Name).Activate
ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen,
Format:=xlPicture
SlideCount = PPPres.Slides.Count
Set PPSlide = PPPres.Slides.Add(SlideCount + 1, ppLayoutBlank)
With PPSlide
.Shapes.Paste
End With
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
SlideCount = SlideCount + 1
Next
End Sub