Embedded charts have events but they must be separately enabled.
That is done by declaring an object of type Chart with events in a class module.
The following code goes in the ThisWorkbook module and displays
a message every time the first embedded chart in the first worksheet
is clicked using the left button.
The Workbook_Open code only needs to be run once.
However, if you make changes to the code,
the Workbook_Open code will usually have to be run again...
'--------------------
'First line goes at the top of the module, just below Option Explicit.
Public WithEvents myChart As Chart
Private Sub myChart_MouseDown(ByVal Button As Long, _
ByVal Shift As Long, ByVal x As Long, ByVal y As Long)
If Button = 1 Then
MsgBox "Please do not copy chart. "
'Deselects chart.
Worksheets(1).Range("A1").Select
End If
End Sub
Private Sub Workbook_Open()
Set myChart = Worksheets(1).ChartObjects(1).Chart
End Sub
-----------------
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
"Mike"
wrote in message
Hi All,
XL 2K Sp3
I have a sheet with several charts on it, that I want to prevent the user
from being able to select the charts (I don't want the chart to be copied as
a chart, as it seems to cause problems)
I set the .protectselection (and .protectformatting, .protectdata, and the
charts' parent chartobject.protectchartobject) properties of my charts to
true and I protect the sheet they are embedded on with drawingobjects:=true.
But, because I am doing some event handling on these charts I need to set
the charts' locked property = false, or else the mouse click events don't
happen.
The problem, if I hold the shift or ctrl button down and then click on the
chart, no event fires, and I am able to select it and can ctrl-c copy it.
I can prevent it by changing the .locked = false to be .locked =true, but
then the charts' mouse click events do not happen. is there a way to catch
or prevent this?
TIA,
Mike.