I have the following code inside a VBA-Script (inside an Excel[openxml]-Sheet):
For Each Co In ThisWorkbook.Worksheets("META").ChartObjects
Co.Delete
Next Co
When I open the Excel File the first time "Co.Delete" throws an "Access Denied"-Error ("You do not have enough privileges to complete this operation")
When I select another sheet and go back to the first sheet and THEN clicke the SAME button like before, calling the method this error is NOT thrown. It looks quite like a Excel-Bug to me.
I know there is no try...catch in VBA and I know I could just insert "on error resume next
" but I just don't want to :)
Is there a different approach like a method "if (Co.DeletionAllowed) Then
" ?