我尝试从Excel模块中的VBA代码运行Power Point应用程序。我首先选择了Microsoft Power Point对象库。但是当我运行下面的代码时,我得到了一个
错误13(类型不匹配)
符合CreateObject函数。我注意到同样的情况是试图定义其他变量Ppp,Spp和Chrt。你知道这个错误的原因是什么吗?
Sub Test()
Dim App As PowerPoint.Application
Dim Ppp As PowerPoint.Presentation
Dim Spp As PowerPoint.Slide
Dim Chrt As PowerPoint.Chart
'Opens Power Point application
Set App = CreateObject("PowerPoint.Application")
'Set App = New PowerPoint.Application
'Makes the application visible (if necessary)
App.Visible = True
'Opens existing power point document
Set Ppp = App.Presentations.Open("C:\Gap\Charts.pptx")
'Sets the second slide
Set Spp = Ppp.Slides(2)
'Sets the chart named "EmbededChart"
Set Chrt = Spp.Shapes("EmbededChart").Chart
End Sub