ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to delete an embedded chart (https://www.excelbanter.com/excel-programming/291398-how-delete-embedded-chart.html)

Tina

How to delete an embedded chart
 
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

Tom Ogilvy

How to delete an embedded chart
 
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

--
Regards,
Tom Ogilvy


Tina wrote in message
om...
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





All times are GMT +1. The time now is 02:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com