I'm trying to create a powerpoint (with templates) from Excel (VBA) and add a textbox to every slide.
The code line, where I want to add the textbox fails with Index out of bounds/No active presentation. What is here wrong? The index of the slide should be ok - there is no change if I set the index manually.
Dim PowerPointApp As Object
Set PowerPointApp = CreateObject("PowerPoint.Application")
PowerPointApp.Visible = True
Set objP = PowerPointApp.Presentations.Add
objP.ApplyTemplate "" & Table1.Range("A1").Value & "draft.pptx"
PowerPointApp.ActivePresentation.Slides.Add 1, ppLayoutTitle
For i = 1 To 10
objP.ApplyTemplate "" & Table2.Range("A1").Value & "template.pptx"
PowerPointApp.ActivePresentation.Slides.Add i + 1, ppLayoutBlank
PowerPointApp.ActivePresentation.Slides(i + 1).Select
Table3.ChartObjects(i).CopyPicture
PowerPointApp.ActivePresentation.Slides(i + 1).Shapes.Paste
PowerPointApp.ActivePresentation.Slides(i + 1).Shapes(1).Top = 150
PowerPointApp.ActivePresentation.Slides(i + 1).Shapes(1).Left = 50
PowerPointApp.ActivePresentation.Slides(i + 1).Shapes(1).Width = 400
PowerPointApp.ActivePresentation.Slides(i + 1).Shapes(1).Height = 300
'Exception occurs here
PowerPointApp.ActivePresentation.Slides(i + 1).Shapes.AddTextbox(msoTextOrientationHorizontal, Left:=100, Top:=100, Width:=200, Height:=50).TextFrame.TextRange.Text = "Text"
Next i
With statement). There could be something outside- in templates or other snippet of your code. But I don't think so...msoTextOrientationHorizontalinto1(yes, single number = 1)