从Excel中打开PowerPoint时出现VBA运行时错误
我目前正在经历一个奇怪的错误。 我们已经开发了一个被许多人使用的工具,其中一个人在得到一台新电脑后出现问题。 macros打开位于networking上的PPT文件(用户可以访问演示文稿 – 我testing了这个文件)。
这里是代码:
Dim ppapp As PowerPoint.Application Dim PPPres As PowerPoint.Presentation Dim MyPath MyPath = Workbooks("MyTool.xls").Sheets("Update").Range("start") Set ppapp = New PowerPoint.Application ppapp.WindowState = ppWindowMinimized ppapp.Visible = True Set PPPres = ppapp.Presentations.Open(MyPath, msoTrue, msoTrue)
该macros在此行失败:
Set PPPres = ppapp.Presentations.Open(MyPath, msoTrue, msoTrue)
运行时错误-2147467259(80004005):PowerPoint无法打开文件奇怪的是,它适用于除一个用户以外的所有用户。 该平台是Win7和Excel 2010。
任何帮助深表感谢!
对我的答案的免责声明,有限的编程和VBA知识。 我唯一的经验是通过excel和word。
办公室的excel参考库是一个问题吗? 如果你把程序运行到不同的系统,那么让代码延迟绑定而不是早期绑定可能会更好。
将Powerpoint应用程序和演示文稿变暗为对象,并更改对其数值的引用。
Dim ppapp As Object Dim PPPres As Object Dim MyPath MyPath = Workbooks("MyTool.xls").Sheets("Update").Range("start") Set ppapp = New PowerPoint.Application ppapp.WindowState = 2 'this would have to be changed to the numerical code; ppWindowMinimized = 2 ppapp.Visible = True Set PPPres = ppapp.Presentations.Open(MyPath, -1, -1) 'these would also may have to be changed, not sure though - -1 = msoTrue.