问题
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