so i am currently doing this…
//Codeblock edited to include otaku upgrade
const String GIFpastespecialformat = @"Picture (GIF)";
const Int32 Onemoreshape = 1;
Int32 shapeCount = sht.Shapes.Count;
WorksheetPasteSpecialArgs wspa = new worksheetpastespecialargs();
wspa.Format = GIFpastespecialformat;
wspa.Link = False;
wspa.DisplayAsIcon = False;
List<Int32> oldShapes = new List<Int32>();
foreach (var item in sht.Shapes.Items())
{
oldShapes.Add(Item.ID);
}
sht.PasteSpecial(wspa);
if((shapeCount + Onemoreshape) == sht.Shapes.Count)
{
foreach (var item in sht.Shapes.Items())
{
if(oldShapes.Exists(i => i == item.ID) == false)
{
//work with shape here
}
}
}
else
{
//report and deal with comexception, user intervention, etc
}
Where sht is the variable representing the worksheet i am working with.
The code is pretty solid. Probably the only enhancement I would make is just keep a count of the shapes –
oldShapes.Countand just see if that number changes after a Paste. If so, a shape has been inserted.