How to delete an image on a sheet

Hi, let's say I have images on my excel sheet, how can I remove / remove them from the sheet using C #,

the following code gives me an exception

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

thanks!

+3
source share
1 answer

It doesn't matter, I forgot that my sheet is protected,

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

it works great!

+2
source

Source: https://habr.com/ru/post/1712780/


All Articles