Hello everyone (anyone),
I am trying to create a macro where I take data tables/slide backgrounds formatted in excel and put them in a power point. I currently use Excel 2010, but have PowerPoint 2013. I am writing this for someone who has all Microsoft Office 2010, and for some reason it just is not working for him. I have written the code this way in order to try and avoid the fact that we have different Microsoft PowerPoint Object Libraries, but apparently when he runs it, it will stop at a slide one, and will not adjust the shapes (I will highlight where the error appears). Any help would be great, kind of doing this as a side job and would love some beer money for the weekend!
Thanks!
Charles
Sub CreateSalesReport()
'Add a reference to the Microsoft PowerPoint Library by:
'1. Go to Tools in the VBA menu
'2. Click on Reference
'3. Scroll down to Microsoft PowerPoint X.0 Object Library, check the box, and press Okay
'First we declare the variables we will be using
Dim newPowerPoint As Object
Dim activeSlide As Object
Dim oShp As Shape
Dim oWB As ThisWorkbook
'Look for existing instance
On Error Resume Next
Set newPowerPoint = CreateObject("PowerPoint.Application")
Set activeSlide = CreateObject("PowerPoint.Slide")
On Error GoTo 0
'Let's create a new PowerPoint
If newPowerPoint Is Nothing Then
Set newPowerPoint = CreateObject("PowerPoint.Application")
End If
'Make a presentation in PowerPoint
If newPowerPoint.Presentations.Count = 0 Then
newPowerPoint.Presentations.Add
End If
'Show the PowerPoint
newPowerPoint.Visible = True
'Add a new slide where we will paste the Sale Report Summary
newPowerPoint.ActiveWindow.View.GotoSlide _
Index:=newPowerPoint.ActivePresentation.Slides.Add(Index:=1, _
Layout:=1).SlideIndex
Set activeSlide = newPowerPoint.ActivePresentation.Slides(newPowerPoint.ActivePresentation.Slides.Count)
'Copy the chart and paste it into the PowerPoint as a Metafile Picture
Sheets("PPT Temp").Select
ActiveSheet.Shapes.Range(Array("PPT Temp")).Select
Selection.Copy
activeSlide.Shapes.Paste
Sheets("Seattle").Select
ActiveSheet.Shapes.Range(Array("Seattle")).Select
Selection.Copy
activeSlide.Shapes.Paste
'Adjust the positioning of the Chart on Powerpoint Slide
newPowerPoint.ActiveWindow.Selection.ShapeRange.Left = 4
newPowerPoint.ActiveWindow.Selection.ShapeRange.Top = 150
activeSlide.Shapes(2).Width = 100
activeSlide.Shapes(2).Height = 100
Bookmarks