PowerPoint Shapes.AddOLEObject Throws Error HRESULT E_FAIL

末鹿安然 提交于 2019-12-25 03:22:03

问题


Following the guidelines from this link, I've wrapped a user control as an ActiveX component. Build the code successfully, and I can confirm that the COM component is registered in Windows registry.

Class name mentioned in registry is "MyChartsControl.UserControl1".

After that I try to add my ActiveX Wrapped user control in PowerPoint Slide object using following code:

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

OR using the ProgId:

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

The code throws the exception given below:

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

Though following code works fine on same slide object if I add picture:

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

Any solution or workaround would be highly appreciated.

来源:https://stackoverflow.com/questions/53450008/powerpoint-shapes-addoleobject-throws-error-hresult-e-fail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!