简体   繁体   English

从Excel VBA打开PowerPoint时出错

[英]Error when opening PowerPoint from Excel VBA

I've searched through a huge number of posts looking for VBA code within Excel which opens a PowerPoint presentation. 我搜索了很多帖子,它们在Excel中寻找VBA代码,从而打开PowerPoint演示文稿。 The vast majority suggest that I use the following code (with variations on the names of variables). 绝大多数建议我使用以下代码(变量名有所不同)。 There are some variations which I have found but none of them work either: 我发现了一些变体,但它们都不起作用:

Dim objPPT As Object
Set objPPT = CreateObject("Powerpoint.Application")
objPPT.Visible = True
objPPT.Presentations.Open "C:\Users\7233025\Desktop\Workmix Resolutions.xlsm"

When I try to run this, the application freezes for about a minute before returning the following error message: 当我尝试运行此命令时,应用程序冻结大约一分钟,然后返回以下错误消息:

Microsoft Excel is waiting for another application to complete an OLE action Microsoft Excel正在等待另一个应用程序完成OLE操作

The application then continues to attempt to run the macro and the only way to stop it is to open the task manager and end the process. 然后,应用程序继续尝试运行宏,而停止宏的唯一方法是打开任务管理器并结束该过程。 This is the case when PowerPoint is open when i attempt to run the code, and when it is closed. 当我尝试运行代码并关闭PowerPoint时打开PowerPoint就是这种情况。

Searching for assistance on the OLE error, most advice is to set the application to 'Ignore other applications that use Dynamic Data Exchange (DDE)' however this does not resolve the problem for me. 在寻求有关OLE错误的帮助时,大多数建议是将应用程序设置为“忽略使用动态数据交换(DDE)的其他应用程序”,但这无法为我解决问题。

As this doesn't seem to be an issue for anyone else in the forums I've searched, is it likely to be something on my employer's network or on the computer preventing the file opening or have I made a mistake somewhere? 对于在我搜索过的论坛中的其他任何人来说,这似乎都不是问题,这是否可能是雇主网络或计算机上的某些文件阻止文件打开,或者我在某个地方犯了错误?

In

objPPT.Presentations.Open "C:\Users\7233025\Desktop\Workmix Resolutions.xlsm"

The file you should try to open should be an ppt file not an excel file. 您应该尝试打开的文件应该是ppt文件而不是excel文件。 Example

objPPT.Presentations.Open "C:\example.pptx"

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

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