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

时间:2022-11-19 22:15:55

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. The platform is Win7 and Excel 2010.

运行时错误-2147467259 (80004005)平台是Win7和Excel 2010。

Any help is much appreciated!

非常感谢您的帮助!

1 个解决方案

#1


1  

Disclaimer on my answer with a limited knowledge of programming and VBA. My only experience is through excel and word.

我对编程和VBA的知识有限,对我的回答予以否认。我唯一的经验是通过excel和word软件。

Is it a problem with the office excel reference library is it? It may be better to make the code late bind rather than early bind if you've got the program go to different systems.

办公excel参考图书馆有问题吗?如果让程序转到不同的系统,那么最好是让代码延迟绑定,而不是提前绑定。

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.

#1


1  

Disclaimer on my answer with a limited knowledge of programming and VBA. My only experience is through excel and word.

我对编程和VBA的知识有限,对我的回答予以否认。我唯一的经验是通过excel和word软件。

Is it a problem with the office excel reference library is it? It may be better to make the code late bind rather than early bind if you've got the program go to different systems.

办公excel参考图书馆有问题吗?如果让程序转到不同的系统,那么最好是让代码延迟绑定,而不是提前绑定。

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.