Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using VBA to Delete a Chart

Suppose I create a chart with

Charts.Add
set thisChart = ActiveChart

Why can't I delete it with

thisChart.Delete?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Using VBA to Delete a Chart

Macro just recorded
Sub Macro3()
'
' Macro3 Macro
' Macro recorded 10/13/2003 by Don Guillett
'

'
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveWindow.Visible = False
ActiveWindow.WindowState = xlNormal
ActiveWindow.WindowState = xlMaximized
End Sub



"MikeM" wrote in message
...
Suppose I create a chart with

Charts.Add
set thisChart = ActiveChart

Why can't I delete it with

thisChart.Delete?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Using VBA to Delete a Chart

Hi:

This worked fine for me:

Sub Test()
Dim thisChart As Chart
Charts.Add
Set thisChart = ActiveChart
thisChart.Delete
End Sub

I did get an alert before the deletion, but that is easily suppressed using
the DisplayAlerts property of the Application object.

Regards,

Vasant.


"MikeM" wrote in message
...
Suppose I create a chart with

Charts.Add
set thisChart = ActiveChart

Why can't I delete it with

thisChart.Delete?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using VBA to Delete a Chart

Sub MakeandBreak()
Charts.Add
Set thisChart = ActiveChart
thisChart.Delete

End Sub

worked fine for me. Prompted if I wanted to delete the chart

Sub MakeandBreak()
Charts.Add
Set thisChart = ActiveChart
Application.DisplayAlerts = False
thisChart.Delete
Application.DisplayAlerts = True
End Sub

that said, this works because ThisChart is visible to the procedure where I
delete it. I suspect that is not your case. You need to declare thischart
as a public variable - do it at the top of a general module outside any
procedure

Public thisChart as Chart

Sub CreateChart
Charts.Add
Set thisChart = ActiveChart
End Sub

Sub deleteChart
Application.DisplayAlerts = False
thisChart.Delete
Application.DisplayAlerts = True
End Sub

that should work.

--
Regards,
Tom Ogilvy




MikeM wrote in message
...
Suppose I create a chart with

Charts.Add
set thisChart = ActiveChart

Why can't I delete it with

thisChart.Delete?




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete chart NonTechie Charts and Charting in Excel 7 September 24th 09 05:59 AM
Delete Chart Event El vengador de la capa Charts and Charting in Excel 3 December 13th 08 11:32 AM
Delete embedded chart, how? Boswell Charts and Charting in Excel 1 December 16th 07 07:08 PM
delete chart Wayne Excel Discussion (Misc queries) 6 May 3rd 07 03:00 PM
Delete Chart agac8103 Charts and Charting in Excel 3 December 13th 04 04:54 AM


All times are GMT +1. The time now is 11:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"