Casting PowertPoint Shape to ShockwaveFlashObjects.ShockwaveFlash?

B

BatKing

Hi,

I am development a com addin for PowerPoint 2007 with VS 2008. I need to
insert some flash objects (.swf files) into the PPT slide. I coded it as the
following

Microsoft.Office.Interop.PowerPoint.Shape shape =
slide.Shapes.AddOLEObject(left, top, width, height,
"ShockwaveFlash.ShockwaveFlash", "", MsoTriState.msoFalse, "", 0, "",
MsoTriState.msoFalse);

try
{
((ShockwaveFlashObjects.ShockwaveFlashClass)shape).Movie =
fileName;
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message.ToString());
}



but I keep getting this exception the in catch statement

"Unable to cast COM object of type 'System.__ComObject' to class type
'ShockwaveFlashObjects.ShockwaveFlashClass'. COM components that enter the
CLR and do not support IProvideClassInfo or that do not have any interop
assembly registered will be wrapped in the __ComObject type. Instances of
this type cannot be cast to any other class; however they can be cast to
interfaces as long as the underlying COM component supports QueryInterface
calls for the IID of the interface."

So I change the code abit to

((ShockwaveFlashObjects.ShockwaveFlash)shape).Movie = fileName;

then I am getting another exception

"Unable to cast COM object of type 'System.__ComObject' to interface type
'ShockwaveFlashObjects.ShockwaveFlash'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{D27CDB6C-AE6D-11CF-96B8-444553540000}' failed due to the following error:
No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE))."

any clue why this is happening?

Thanks.
 
B

BatKing

Never mind, I solve the problem.

the shape need to be shape.oldFormat.object before casting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top