sanfrandear
New Member
- Joined
- Aug 20, 2019
- Messages
- 4
I have a macro here that works fine when creating a new presentation, but now I have a specific layout that I need to use from an existing presentation . So I was thinking I could open the presentation and add a new slide for every loop. I tried the getobject method but kept running into an error.
I tried the following methods but ran into an error:
1.
2.
Code:
Sub FilterPackage()
Dim newppt As PowerPoint.Application
Dim activeSlide As PowerPoint.Slide
On Error Resume Next
Set newppt = GetObject(, "PowerPoint.Application")
On Error GoTo 0
If newppt Is Nothing Then
Set newppt = New PowerPoint.Application
End If
If newppt.Presentations.Count = 0 Then
newppt.Presentations.Add
End If
'For Loop to filter and then export charts as picture to new slide
For i = 1 To lastcolumn
l
'Create new slide
newppt.ActivePresentation.Slides.Add newppt.ActivePresentation.Slides.Count + 1, ppLayoutTitleOnly
newppt.ActiveWindow.View.GotoSlide newppt.ActivePresentation.Slides.Count
Set activeSlide = newppt.ActivePresentation.Slides(newppt.ActivePresentation.Slides.Count)
activeSlide.Select
activeSlide.Shapes.Title.TextFrame.TextRange.Text = rangetitle
'code pastes graphs onto new slide
Next i
End Sub
I tried the following methods but ran into an error:
1.
Code:
Set MyPresentation = objNewPowerPoint.Presentations.Open(filepath)
2.
Code:
Dim oPPT As PowerPoint.Application
Dim oPres As Object
Dim oSlide As Object
Set oPPT = GetObject(, "PowerPoint.Application")
Set oPres = oPPT.Presentations(filepath)
Set oSlide = oPres.Slides.Add(oPres.Slides.Count + 1, 12) 'ppLayoutBlank