无法将“System .__ ComObject”类型的COM对象强制转换为接口类型“Microsoft.Office.Interop.PowerPoint.Presentation”

时间:2013-02-18 09:30:53

标签: c# vb.net c#-4.0

我正在使用MSWord 2003当前并创建一个Powerpoint对象,然后应用模板。在这些方面我设置了一个例外。

  

“无法将'System .__ ComObject'类型的COM对象强制转换为接口   输入“Microsoft.Office.Interop.PowerPoint.Presentation”。这个   操作失败,因为QueryInterface调用COM组件   用于IID'{9149349D-5A91-11CF-8700-00AA0060263B}的接口   由于以下错误而失败:不支持此类接口   (HRESULT异常:0x80004002(E_NOINTERFACE))。“

    ((Microsoft.Office.Interop.PowerPoint.Presentation)objPresentation).Tags.Add("Carma DocSys~XML", m_Model.Document.get_Data.OuterXml);
    objMaster = ((Microsoft.Office.Interop.PowerPoint.Presentation)objPresentation).TitleMaster;

代码是

        object objApplication; //As Object ' PowerPoint.Application
        object objPresentation = new object();  // As Object ' PowerPoint.Presentation
        string strTemplate;//     As String

        objApplication = new Microsoft.Office.Interop.PowerPoint.Application();
       strTemplate = Convert.ToString(ndModel.GetAttribute("template"));
       objPresentation ((Microsoft.Office.Interop.PowerPoint.Application)objApplication).Presentations.Add();
      ((Microsoft.Office.Interop.PowerPoint.Presentation)objPresentation).ApplyTemplate(strTemplate);

      ((Microsoft.Office.Interop.PowerPoint.Presentation)objPresentation).Tags.Add("Carma DocSys~XML", m_Model.Document.get_Data.OuterXml);

   objMaster = ((Microsoft.Office.Interop.PowerPoint.Presentation)objPresentation).TitleMaster;

0 个答案:

没有答案