![](/img/trans.png)
[英]Excel VBA Error 467 when trying to open a PowerPoint presentation
[英]VBA fails when opening PowerPoint presentation on Windows 7
我在 Windows XP 上的 Excel 2007 中编写了一个 VBA 宏,用于将数据从 excel 电子表格复制到 PowerPoint 演示文稿中。 当这个启用宏的电子表格在全新安装的 Windows 7 上运行时,它会失败。 因此,我提取了无法确定问题的代码,并且在尝试打开现有的 powerpoint 文件时似乎失败了。 我已尝试在 Office 2010 和 Office 2007 中运行此代码。
我正在尝试使用它的代码(只是下面显示的问题部分)
Sub test()
Dim PowerPointApplication As PowerPoint.Application
Dim PowerPointFile As PowerPoint.Presentation
Set PowerPointApplication = CreateObject("PowerPoint.Application")
Set PowerPointFile = PowerPointApplication.Presentations.Open("PATH_TO_FILE\test.pptx")
End Sub
宏在上面的 Presentations.Open 行上失败,并出现以下错误
Run-time error '-2147467259 (80004005)':
Method 'Open' of object 'Presentations' failed
我已经在电子表格的 VBEditor 的引用设置中启用了 PowerPoint 12.0 对象库。 所有其他引用都与在我的 Windows XP 机器上运行且没有错误的文件完全匹配。
我在网上到处寻找答案,但找不到任何东西。 我阅读了一些有关 Windows 7 和脱机文件的信息,因此尝试将其关闭,但没有帮助。
我也以管理员用户身份登录,并尝试将我正在打开的 pptx 也移动到其他目录,但没有成功。
我正在运行以下版本的 Windows:
Windows 7 Professional
Service Pack 1
64 Bit
任何帮助,将不胜感激!
PATH_TO_FILE 是变量(或常量)吗?
如果是这样不应该
PowerPointFile = PowerPointApplication.Presentations.Open(PATH_TO_FILE & "\test.pptx")
这确实适用于 Win7 SP1 64 位操作系统上的 office 2016
应该适用于 Office 2010。
也可能是约翰对文件路径的建议。
Sub test()
Dim PowerPointFile As PowerPoint.Presentation
Dim PPTObj As Object
Set PPTObj = CreateObject("PowerPoint.application")
Set PowerPointFile = PPTObj.Presentations.Open("C:\test.pptx")
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.