我正在尝试获得powerpoint演示文稿的处理程序。通常,我使用以下指令:
Set pres = PowerPoint.application.Presentations(pptFile)
我收到以下错误消息:
'activex组件无法创建对象'
pptFile应该已经打开
任何想法?
答案 0 :(得分:4)
如果您不想两次打开相同的演示文稿,请执行以下操作:
Dim pptFile As String
pptFile = "C:\Users\" & Environ$("username") & "\Desktop\ppp.pptx"
Dim pptApp As PowerPoint.Application
Set pptApp = New PowerPoint.Application
Dim pres As Presentation
For Each pres in pptApp.Presentations
If pres.FullName = pptFile then
' found it!
Exit For
End If
End If
' And possibly do this to open the file if it's not already open
If pres Is Nothing Then
Set pres = pptApp.Presentations.Open(pptFile)
End If
答案 1 :(得分:0)
您也可以尝试以下命令:
Set pres = GetObject(pptFile)
如果文件未打开,自动化将打开文件,如果文件已经打开,它将不会再次打开文件。