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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export charts from Excel into PowerPoint

Status
Not open for further replies.

work4livinsean

Programmer
Mar 28, 2006
23
US
Hi everyone, I need to export a chart from Excel into PowerPoint on multiple slides. I got this code to work! The problem is that I want it to place the charts on lets say slides 1, 3, and 5. Right now the code places the chart in sequencial order. I was thinking for the if statement to place a statement like the:

'If slideindex = 1 or slideindex = 3 or slideindex = 5 Then'

Please help!

Sub TestNew()

Dim objPPT As Object
Dim objPrs As Object
Dim shtTemp As Worksheet
Dim chtTemp As ChartObject
Dim intSlide As Integer

Set objPPT = CreateObject("Powerpoint.application")
objPPT.Visible = True
objPPT.presentations.Open ThisWorkbook.Path & "\TestPP.ppt"

For Each shtTemp In ThisWorkbook.Worksheets
For Each chtTemp In shtTemp.ChartObjects
intSlide = intSlide + 1
chtTemp.CopyPicture
If intSlide > objPPT.presentations(1).Slides.Count Then 'I think this if statement needs to be changed
objPPT.ActiveWindow.View.GotoSlide Index:=objPPT.presentations(1).Slides.Add(Index:=intSlide, Layout:=1).slideindex
Else
objPPT.ActiveWindow.View.GotoSlide intSlide
End If
objPPT.ActiveWindow.View.Paste 'This may have to be moved if the if statement is changed
Next
Next

Set objPrs = Nothing
Set objPPT = Nothing

End Sub


Thanks in advanced!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top