Good day,
I am using the following code to paste excel generated graphs into a powerpoint presentation
Sub Chart2PPT()
Dim objPPT As Object
Dim objPrs As Object
Dim shtTemp As Worksheet
Dim chtTemp As ChartObject
Dim intSlide As Integer
intSlide = 1
Set objPPT = CreateObject("Powerpoint.application")
objPPT.Visible = True
objPPT.presentations.Open Filename:="filename.pptx"
'objPPT.ActiveWindow.ViewType = 1 'ppViewSlide
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
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
Next
' objPPT.presentations(1).Save
' objPPT.Quit
Set objPrs = Nothing
Set objPPT = Nothing
End Sub
I would like to run this code on a weekly basis and have the graphs update with the latest graphs instead of just pasting on top of the old ones. what code can I use to clear the previous old graph before pasting the new graphs
thanks
Bookmarks