使用 Excel 2010 的类字符串无效
我有一个第三方旧版软件,它使用自动化来控制 MS Excel(使用 MFC/C++)。代码很简单:
_ApplicationPtr xl;
HRESULT hr = xl.CreateInstance("Excel.Application");
从 Excel 2000、2002 (XP)、2003 和 2007 开始,这一切都完美运行;但是,安装 Office 2010 后,CreateInstance 调用失败并显示“无效类字符串”(CO_E_CLASSSTRING)。我需要做什么特别的事情才能让它发挥作用吗?
提前致谢!
I have a third-party legacy software that uses Automation to control MS Excel (using MFC/C++). The code is straightforward:
_ApplicationPtr xl;
HRESULT hr = xl.CreateInstance("Excel.Application");
This worked perfectly since Excel 2000, 2002 (XP), 2003 and 2007; however, after installing Office 2010, the CreateInstance call fails with "Invalid Class String" (CO_E_CLASSSTRING). Is there anything special I need to do to get this to work?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
类字符串是
"Excel.Application"
部分,大概是 Microsoft 在 Office 2010 中进行了更改。通常,它类似于“Excel9.Application”代表“真实”值,“Excel”代表“实际”值。 .Application”指向最新版本的特定条目。可能是 MS 停止添加指针条目,或者您的注册表在升级过程中被搞乱了。
The class string is the
"Excel.Application"
part, which, presumably, Microsoft has changed in Office 2010.Normally, it's something like "Excel9.Application" for the "real" value, and "Excel.Application" pointing to the latest version specific entry. It's possible the MS stopped adding the pointer entry, or your registry got messed up in the upgrade.