Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Deleting all charts in workbook or worksheet

1 view
Skip to first unread message

dushkin

unread,
Jul 12, 2009, 6:12:54 AM7/12/09
to
Hi,
I am trying to delete all charts I have in my wotrkbook.

I tried this code:

Charts charts = a_wb.GetCharts();
while (charts.GetCount() > 0) {
_Chart chrt = charts.GetItem((COleVariant)((short)1));
chrt.Delete();
}

and many more algorithms...

Nothing works for me!!!

Can someone help please???

Thanks.

Alan Moseley

unread,
Jul 14, 2009, 4:53:02 AM7/14/09
to
Try the following:-

Public Sub delcharts()
Dim ws As Worksheet
Dim cht As Object
If ThisWorkbook.Charts.Count > 0 Then
'The next line deletes all chart sheets
ThisWorkbook.Charts.Delete
End If
'The code below removes all embedded charts
For Each ws In ThisWorkbook.Sheets
For Each cht In ws.ChartObjects
cht.Delete
Next
Next
End Sub
--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.

dushkin

unread,
Jul 14, 2009, 6:55:32 AM7/14/09
to
Thanks!

AnAmericanInDublin

unread,
Sep 1, 2009, 5:41:02 AM9/1/09
to
Thanks for that. I wasn't looking to delete all the charts, just looking for
a handy way to enumerate all the charts in a workbook.

Cheers!

0 new messages