PowerPoint Shapes.AddOLEObject引发错误HRESULT E_FAIL

时间:2018-11-23 16:19:44

标签: c# vb.net office-interop powerpoint-vba office-addins

按照this link中的指南,我将用户控件包装为ActiveX组件。成功构建代码,然后我可以确认COM组件已在Windows注册表中注册。

注册表中提到的类名称为“ MyChartsControl.UserControl1”。

之后,我尝试使用以下代码在PowerPoint Slide对象中添加ActiveX Wrapped用户控件:

powerpointSlideObject.Shapes.AddOLEObject(100, 100, 111, 222, ClassName:="MeridiaChartsControl.UserControl1")

或使用ProgId:

powerpointSlideObject.Shapes.AddOLEObject(100, 100, 111, 222, ClassName:="ActiveXTestLibrary.UserControl")

代码抛出以下异常:

Error HRESULT E_FAIL has been returned from a call to a COM component.

如果添加图片,以下代码可在同一幻灯片对象上正常工作:

powerpointSlideObject.Shapes.AddPicture("d:\\temp\\image1.png", MsoTriState.msoFalse, MsoTriState.msoCTrue, 400, 150)

任何解决方案或解决方法都将受到高度赞赏。

0 个答案:

没有答案
相关问题