You have two errors in your code.
Simoco has already addressed your first error. i.e you need to use
Cells(i, 15).Value
instead ofrange(Cells(i, 15)).Value
You have a typo. If you would have used
Option Explicit
then you would have known where the error is ;)
You have PPApp
as the powerpoint object but are using PApp
and hence the object required error
Also please declare your variables and fully qualify your objects.
Is this what you are trying?
Option Explicit
Sub GetText()
Dim PPApp As Object
Dim ws As Worksheet
Dim i As Long
Set PPApp = GetObject(, "PowerPoint.Application")
i = 1
'~~> Change this to the relevant sheet
Set ws = ThisWorkbook.Sheets("Sheet1")
Do While i <= PPApp.ActivePresentation.Slides(1).Shapes.Count
If PPApp.ActivePresentation.Slides(1).Shapes(i).Type = msoTextBox Then
ws.Cells(i, 15).Value = PPApp.ActivePresentation.Slides(1).Shapes(i).TextFrame.TextRange.Text
End If
i = i + 1
Loop
End Sub
Few Other observations.
You are using
GetObject
. If there are multiple instances of powerpoint then you many not get the correct result.You are incrementing the value of
i
even when the shape is notmsoTextBox
. This may result in you skipping the rows while writing to the Excel Sheet. You may want to use a different variable and increment that inside theIf-EndiF