我正在使用 MSWord 2003 current 并创建一个 Powerpoint 对象,然后应用模板。在这些方面,我发现了一个例外。
“无法将类型为“System.__ComObject”的 COM 对象转换为接口类型“Microsoft.Office.Interop.PowerPoint.Presentation”。此操作失败,因为对具有 IID 的接口的 COM 组件调用 QueryInterface '{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;