Run time error on SaveAs line of code

OliverBrain

New Member
Joined
Mar 19, 2015
Messages
30
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!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,214,920
Messages
6,122,267
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top