【问题标题】:Getting name of each open PPT presentation using VBA使用 VBA 获取每个打开的 PPT 演示文稿的名称
【发布时间】:2018-12-30 20:41:03
【问题描述】:

我想使用以下代码获取每个打开的 PPT 演示文稿的名称。 问题是我在代码的“For each”行中收到错误消息“ActiveX 组件无法创建对象”。

提前感谢您的帮助!

PS:奇怪的事情:我从这里完全复制了代码:http://vba.relief.jp/powerpoint-macro-get-all-open-presentations-name/

Sub GetAllOpenPresentationsName()

Dim prs As Presentation


For Each prs In Presentations

Debug.Print prs.Name

Next prs

End Sub

【问题讨论】:

  • 您是在 Powerpoint 中执行此操作吗?

标签: vba powerpoint


【解决方案1】:

欢迎来到 SO。您似乎不在 PowerPoint VBA 中工作。如果在其他平台上工作,请尝试

Sub GetAllOpenPresentationsName()
Dim prs As Presentation
Dim PP As PowerPoint.Application
On Error Resume Next
Set PP = GetObject(, "PowerPoint.Application")
    If Err Then
    Debug.Print "PowerPoint is not Open"
    Err.Clear
    Exit Sub
End If
On Error GoTo 0
For Each prs In PP.Presentations
Debug.Print prs.Name
Next prs
End Sub

【讨论】:

  • QHarr:在 Excel 中没有,我认为这是问题 Ahmed AU:非常感谢!它工作得很好:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-05
  • 2015-10-14
  • 1970-01-01
  • 2012-08-04
  • 2023-02-24
相关资源
最近更新 更多