Word.Document doc = app.Documents.Open(ref path, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,ref missing, ref missing, ref missing, ref missing, ref missing);
Word.Shapes shapes = doc.Shapes;
int delCtr = 0;
for (int i = 1; i + delCtr <= shapes.Count; i++)
{
// Casting to IRuntimeStorage causes .NET to perform a QI for the interface
// This will succeed only on an ActiveX control that implements IRuntimeStorage
try
{
object i_obj = i;
VSTOStgLib.IRuntimeStorage rsc = (VSTOStgLib.IRuntimeStorage)shapes.get_Item(ref i_obj).OLEFormat.Object;
// If cast succeeds we have a RSC. Delete it.
shapes.get_Item(ref i_obj).Delete();
delCtr++;
i--;
}
catch (InvalidCastException) {
// Do nothing. This is not a RSC.
}
}
doc.Save();
doc.Close(ref missing, ref missing, ref missing);