Home > Net >  Object Required Error - Populate PPT from Word using VBA
Object Required Error - Populate PPT from Word using VBA

Time:05-05

Sub SendToPPT()

Dim ppt As Object
Set ppt = CreateObject("Powerpoint.Application")

ppt.Presentations.Open ActivePresentation.Path & "\" & "Allegation.pptx"

For i = 6 To 24
ppt.Slides(i).Shapes(1).TextFrame.TextRange = ActiveDocument.Paragraphs(i).Range.Text
Next i

ppt.Save
ppt.Close
Set ppt = Nothing

End Sub

I'm receiving a

Run time Error 424: Object Required.

I'm unable to figure out where I'm going wrong. The file path is correct, I've cross-checked it.

CodePudding user response:

ppt is the "Powerpoint.Application" but ppt.Slides(i) expects a presentation not the powerpoint application.

Dim Pres As Object
Set Pres = ppt.Presentations.Open(ActivePresentation.Path & "\" & "Allegation.pptx")

Dim i As Long
For i = 6 To 24
    Pres.Slides(i).Shapes(1).TextFrame.TextRange = ActiveDocument.Paragraphs(i).Range.Text
Next i

Pres.Save
Pres.Close
Set Pres = Nothing
Set ppt = Nothing
  • Related