View Single Post
  #9   Report Post  
Tushar Mehta
 
Posts: n/a
Default

Hi Andy,

That's a nice idea -- with limited applicability. If someone selects
the chartobject (or selects multiple charts which causes XL to
automatically select the associated chartobjects), the Deactivate event
is not triggered.

The only way that I have been able to think of to detect with certainty
the creation of new charts and the deletion of existing charts is to
have MS enhance the XL object model (or, of course, use a timer, which
can have its own set of issues).

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
Hi ,

Add this to your chart event class.

'------------------------------------------------
Option Explicit

Public WithEvents MyCht As Chart

Private Sub MyCht_Deactivate()
'
' Checks the chartobjects name property
' If the chart has been deleted then this will cause an error
'
On Error GoTo ErrDeactivate
If Me.MyCht.Parent.Name < "" Then
MsgBox "Only deactivated"
End If
Exit Sub

ErrDeactivate:
MsgBox "Somebody deleted our chart", vbExclamation
Exit Sub
End Sub
'------------------------------------------------

Cheers
Andy

wrote:
Well, I kind of have to worry about it. We have implemented dynamic
charts and have some things still laying around (data), including a
copy of a chart object (required to preserve some charting
information), that need to be cleaned up after the chart is deleted.
Since VBA doesn't provide some sort of event to trap deletes or a
destructor like the rest of the object oriented world, we have to
figure out something else.. A timer won't be sufficent or desirable
here. Thanks for the thoughts though.

roy