简体   繁体   English

无法区分类型的COM对象

[英]Unable to case COM object of type

I'm getting a strange error when I'm trying to do a foreach through shapes on a page using Word interop 当我尝试使用Word interop通过页面上的形状进行foreach时遇到一个奇怪的错误

My code is as follows 我的代码如下

    foreach (word.Shapes p in pages[3].Application.ActiveDocument.Shapes )
    {
        p.SelectAll();
    }

The exception I get for some reason is this and I've no idea what I should do to fix this. 由于某种原因,我得到的例外是这个,我不知道该如何解决。

{"Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Word.Shapes'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{0002099F-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."} {“无法将类型'System .__ ComObject'的COM对象转换为接口类型'Microsoft.Office.Interop.Word.Shapes'。此操作失败,因为对IID为'{0002099F-0000”的接口的COM组件上的QueryInterface调用-0000-C000-000000000046}由于以下错误而失败:不支持此类接口(HRESULT的异常:0x80004002(E_NOINTERFACE))。“}

Shapes是集合类型,但是要迭代形状,必须为每个对象使用Shape作为类型。

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

相关问题 无法将COM对象强制转换为类类型 - Unable to cast COM Object to class type 无法转换类型异常的COM对象 - Unable to cast COM object of type exception 使用ExeCOMServer时,无法将类型为“...”的COM对象转换为接口类型“...” - Unable to cast COM object of type '…' to interface type '…' while using an ExeCOMServer InvalidCastException:无法将类型x的COM对象转换为接口类型y - InvalidCastException: Unable to cast COM object of type x to interface type y :'无法将类型为'System .__ ComObject'的COM对象转换为接口类型 - : 'Unable to cast COM object of type 'System.__ComObject' to interface type 无法使用 STAThread 属性转换类型为“System.__ComObject”的 COM 对象 - Unable to cast COM object of type 'System.__ComObject' with STAThread attribute 无法转换类型为'System .__ ComObject'的COM对象 - Unable to cast COM object of type 'System.__ComObject' 无法转换'System .__ ComObject类型的COM对象 - Unable to cast COM object of type 'System.__ComObject 无法投射 COM object - Unable to cast COM object 在C#中加载COM对象抛出异常“无法将类型为'System .__ ComObject'的COM对象转换为接口类型...”,但C ++或VB没有 - Loading COM object in C# throws exception “Unable to cast COM object of type 'System.__ComObject' to interface type …”, but C++ or VB not
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM