views:

110

answers:

1

hi let's say i have images on my excel worksheet, how is it possible to delete/remove them from the sheet using c#,

following code gives me exception

        Excel.Worksheet ws = Globals.ThisAddIn.GetActiveWorksheet();
        foreach (Excel.Shape sh in ws.Shapes)
        {
            sh.Delete();
        }

thanks!

+2  A: 

never mind, i forgot that my sheet was protected,

    Excel.Worksheet ws = Globals.ThisAddIn.GetActiveWorksheet();
    ws.Unprotect("PASSWORD");
    foreach (Excel.Shape sh in ws.Shapes)
    {
        sh.Delete();
    }

it works fine!