How to delete an embedded chart

T

Tina

Hi,
I am trying to delete an embedded chart from a protected sheet. But i
am getting errors like "select method of chartarea class failed". Can
anyone help?
Here is the code:

Dim ws As Worksheet
Dim chObj As ChartObject
Set ws = ActiveSheet
For Each chObj In ActiveSheet.ChartObjects
chObj.Chart.ChartArea.Select '*** error here
ActiveWindow.Visible = False
Selection.Delete
Next chObj


Thanks
Gunjan Salgia
 
T

Tom Ogilvy

Dim ws As Worksheet
Dim chObj As ChartObject
Set ws = ActiveSheet
ws.unprotect
For Each chObj In ActiveSheet.ChartObjects
chobj.Delete
Next chObj
ws.protect
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top