我尝试运行此代码以删除任何图表,然后才允许代码运行,但错误是"对象不支持此方法"不断上升。
Dim wksht As Worksheets
Set Source_Workbook = ThisWorkbook
For Each wksht In Source_Workbook
If ChartObjects.Count > 0 Then
ChartObjects.Delete
End If
Next wksht
答案 0 :(得分:2)
这是更正后的代码:
Sub DeleteAllChartObjects()
Dim wksht As Worksheet
For Each wksht In ThisWorkbook.Worksheets
If wksht.ChartObjects.count > 0 Then wksht.ChartObjects.Delete
Next wksht
End Sub
答案 1 :(得分:0)
您需要枚举每个图表并单独删除它。您正试图删除该集合。