简体   繁体   English

从Excel打开PowerPoint时的VBA运行时错误

[英]VBA run-time error when opening PowerPoint from Excel

I am currently experiencing a strange error. 我目前遇到一个奇怪的错误。 We have developed a tool that is used by many people and ONE of them has problems after he got a new computer. 我们开发了一种可供许多人使用的工具,在他获得一台新计算机后,其中一个人遇到了问题。 The macro opens a PPT file located on the network (the user has access to the presentation - I tested this). 宏会打开位于网络上的PPT文件(用户可以访问演示文稿-我对此进行了测试)。

Here is the code: 这是代码:

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)

The macro fails at this line: 宏在此行失败:

Set PPPres = ppapp.Presentations.Open(MyPath, msoTrue, msoTrue)

Run-time error -2147467259 (80004005): PowerPoint could not open the file The strange thing is that it works for all users except one. 运行时错误-2147467259(80004005):PowerPoint无法打开文件。奇怪的是,它适用于除一个用户之外的所有用户。 The platform is Win7 and Excel 2010. 该平台是Win7和Excel 2010。

Any help is much appreciated! 任何帮助深表感谢!

Disclaimer on my answer with a limited knowledge of programming and VBA. 我对编程和VBA的了解有限,因此对我的回答不承担任何责任。 My only experience is through excel and word. 我唯一的经验是通过Excel和Word。

Is it a problem with the office excel reference library is it? Office Excel参考库有问题吗? It may be better to make the code late bind rather than early bind if you've got the program go to different systems. 如果您将程序转到其他系统,则使代码晚绑定而不是早绑定可能更好。

Dim the Powerpoint application and presentation as objects and change references to their numerical values. 将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.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM