我有一个小型应用程序,可以通过 COM/OLE 自动化实现 Microsoft Word 的自动化。
不幸的是,这不适用于虚拟化的即点即用版本的 Word,因为它们在注册表中没有所需的密钥。 (至少不是预期的位置)换句话说:CreateObject
失败,因为未注册必要的 COM 类。
是否有任何方法可以自动执行 Microsoft Office 的即点即用版本?也许有一些兼容层?
编辑:我发现只有两个页面中有用户/开发人员抱怨这一点。要么 OLE 自动化已经过时,要么没有人使用 C2R 版本......
I have a small application which automates Microsoft Word via COM/OLE Automation.
Unfortunately this doesn't work with the virtualized Click-to-run editions of Word, because they don't have the required keys in the registry. (At least not where they are exptected to be) In other words: CreateObject
fails because the necessary COM classes are not registered.
Is there any way to automate the Click-to-run editions of Microsoft Office? Perhaps some compatibility layer?
EDIT: I found just two pages where users/developers were complaining about this. Either OLE automation has become obsolete or no one is using the C2R editions...
发布评论
评论(3)
遗憾的是,即点即用 Office 版本无法实现自动化。这是由于使用了虚拟化过程。
根据 此处的信息 您可以将 C2R 版本切换到 MSI 版本。两个版本的许可证和产品密钥似乎都是相同的。
Unfortunately it's not possible to do automation with the Click-To-Run Office editions. It's due to the virtualization process used.
According to the information here you can switch your C2R-edition to a MSI edition. It seems like the license is the same for both editions and also the product key.
我花了几天时间才发现这篇文章证实了我的怀疑。对于任何拥有依赖于自动化的应用程序的人来说,微软确实搞砸了这一点。
对于任何谷歌用户来说,我在我的应用程序中看到的错误是:
由于以下错误,检索具有 CLSID {91493441-5A91-11CF-8700-00AA0060263B} 的组件的 COM 类工厂失败:
80040154要解决此问题,请卸载 Office 即点即用版本并进行完整安装。
It took me a few days to find this post verifying my suspicions. Microsoft really screwed this one up for anyone with an app depending on automation it seems.
For any googlers out there, the error I've been looking at in my app is:
Retrieving the COM class factory for component with CLSID {91493441-5A91-11CF-8700-00AA0060263B} failed due to the following error: 80040154
I was able to resolve this by uninstalling the office click-to-run version and doing a full install.
根据 https://answers.microsoft.com/en-us/msoffice/forum/all/office-click-ro-run-and-ole-automation/abc2fe0d-58e4-42eb-84ef- a6e7c1c7b3f4, "我自己找到了解决方案。通过即点即用,Office 安装不会在 HKCR\Typelib 中注册类型库。而是在 HKLM\SOFTWARE\Microsoft\Office\ClickToRun\REGISTRY\ 中注册类型库MACHINE\SOFTWARE\Classes\TypeLib 中运行的 VBA 可以识别该位置,并且外部应用程序无法识别该位置,因此解决方案是在 mso.dll 上运行 regtlib.exe 以在 HKCR\ 中注册 Office 类型库。 Typelib 以便外部应用程序可以正确运行 OLE 自动化。”
According to https://answers.microsoft.com/en-us/msoffice/forum/all/office-click-ro-run-and-ole-automation/abc2fe0d-58e4-42eb-84ef-a6e7c1c7b3f4, "I have found the solution myself. With click-to-run, Office installation does not register typelibs in HKCR\Typelib. Instead, it registers typelibs in HKLM\SOFTWARE\Microsoft\Office\ClickToRun\REGISTRY\MACHINE\SOFTWARE\Classes\TypeLib. VBAs running in Office is aware of the location and runs fine. External application is not aware of the location. So the solution is to run regtlib.exe on mso.dll to register Office typelibs in HKCR\Typelib so that external applications can run OLE Automation correctly."