Can anyone tell why I am getting a run time error when the last line of this code is run (.SaveAs FileName)?
Code:
Sub CreateNewPres()
Dim FileName As String
Dim rng1 As Excel.Range
Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppSlide As PowerPoint.Slide
'Sets the first range we want to copy
Set rng1 = ThisWorkbook.Worksheets("Sheet3").Range("rng_1")
'Opens Powerpoint
Set ppApp = New PowerPoint.Application
ppApp.Visible = True
ppApp.Activate
'Adds new presentation and Title slide
Set ppPres = ppApp.Presentations.Add
Set ppSlide = ppPres.Slides.Add(1, ppLayoutTitle)
'Refers to the shapes within the title slide and input what you want
ppSlide.Shapes(1).TextFrame.TextRange = "End of Pilot Presentation"
ppSlide.Shapes(2).TextFrame.TextRange = "Client Name"
'Adds second slide
Set ppSlide = ppPres.Slides.Add(2, ppLayoutBlank)
ppSlide.Select
'Copies and pastes rng_1
rng1.Copy
ppSlide.Shapes.Paste
'Moves the table of data into the top left corner of the slide
ppSlide.Shapes(1).Left = 234
ppSlide.Shapes(1).Top = 234
'Selects the first chart object in the specified worksheet
ThisWorkbook.Worksheets("Sheet3").ChartObjects(1).Chart.CopyPicture _
Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
'Doesn't seem to like this jump in code
ppSlide.Shapes.Paste
ppSlide.Shapes(1).IncrementLeft -100
'can set it to the width of the slide i.e. width = ppPres.PageSetup.SlideWidth
'Establishes the Filename
FileName = "Pilot Presentation" & " " _
& Format(Now, "dd-mmm-yy")
'Saves the Presentation using the FileName
With ppSlide.Parent
.SaveAs FileName
End With
End Sub
Thanks for the help!
Bookmarks