对象所需的错误 - 使用VBA从Word中填充PPT

发布于 2025-01-25 21:23:53 字数 455 浏览 5 评论 0原文

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

我正在收到一个

运行时间错误424:必需对象。

我无法弄清楚我出错的地方。文件路径是正确的,我已经对其进行了交叉检查。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

失退 2025-02-01 21:23:53

ppt“ PowerPoint.Application”ppt.slides(i)期望演示文稿而不是PowerPoint应用程序。

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文