Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to Create Slides of Excel charts not working in Excel 2010

Status
Not open for further replies.

shelby55

Technical User
Jun 27, 2003
1,229
0
0
CA
Hello

The code below copies Excel charts to a Powerpoint Presentation and was created in Excel 2003 and doesn't work in Excel 2010. Can someone advise why that might be?

Thanks.

Code:
Sub CopyCharts_ED()
Dim oppt As New PowerPoint.Application
Dim pptpres As Presentation
Dim pptslide As Slide
Dim ch As Chart
Dim wkb As Workbook


'create new presentation
oppt.Visible = msoTrue


Set pptpres = oppt.Presentations.Add
With pptpres.Slides

'lheight = pptpres.PageSetup.SlideHeight
'lwidth = pptpres.PageSetup.SlideWidth

'place each chart in slide

For Each ch In ActiveWorkbook.Charts

ch.CopyPicture Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture

Set wkb = ActiveWorkbook

Set pptslide = .Add(.Count + 1, ppLayoutBlank)
pptslide.Shapes.PasteSpecial , , , , , msoFalse

With pptslide.Shapes(1)
.Top = 10
.Left = 10
.LockAspectRatio = msoFalse
.ScaleHeight 1, msoTrue
.ScaleWidth 1, msoTrue
End With

Next ch

End With
End Sub

 
Hi

I figured it out. It was a references issue in the Excel document not selecting Microsoft PowerPoint Object Library. I selected that and it works now.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top