seagull
seagull

Reputation:

how to delete an image on a sheet

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!

Upvotes: 3

Views: 2761

Answers (1)

seagull
seagull

Reputation:

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!

Upvotes: 2

Related Questions