I am trying to get a list of excel files in a sheet and trying to add all the charts to a powerpoint. I do not even know if this should work this way but then when i run it it gives me a script 9 out of range error. Can someone tell me a better way to do this.
Also if i need few charts and not all and if i list them on sheet1., how can i get them in powerpoint.
Thanksssssssssssssssss
Brat
Sub Chart2PPT()
'Declarations
Dim objPPT As Object
Dim objPrs As Object
Dim shtTemp As Worksheet
Dim chtTemp As Chart
Dim intSlide As Integer
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
'Delete existing powerpoint slide
Set FSO = New FileSystemObject
If FSO.FileExists("\\Kpserver4\metrics\metrics.ppt") Then
Kill ("\\Kpserver4\metrics\metrics.ppt")
End If
'get count of number of workbooks to be imported
chartnum = 1
For I = 1 To 100
If Sheet1.Cells(I, 1) <> "" Then
chartnum = chartnum + 1
End If
Next I
'Create New powerpoint slide
Set objPPT = CreateObject("Powerpoint.application")
objPPT.Visible = True
objPPT.presentations.Add
objPPT.ActiveWindow.ViewType = 1 'ppViewSlide
'Add graphs from existing power point
For Each chtTemp In ActiveWorkbook.Charts
intSlide = intSlide + 1
With chtTemp
.Activate
.ChartArea.Select
.CopyPicture
End With
If intSlide > objPPT.presentations(1).Slides.Count Then
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
Next
Workbooks(wrkbk & ".xls").Close
Workbooks("\\Kpserver4\metrics\Update metrics.xls").Activate
Next I
'Save powerpoint and close
objPPT.presentations(1).SaveAs ("\\Kpserver4\metrics\metrics.ppt")
objPPT.Quit
Set objPrs = Nothing
Set objPPT = Nothing