I have an excel sheet containing several charts & tables, the sheet is protected and all charts are locked.
I would like to make it possible for the users to copy the charts.
Either by right clicking and selecting copy or by triggering a macro at when clicking or double clicking a chart.
I’ve tried playing around with the locked property of a chart & the
ActiveChart.ProtectSelection but if the chart is unlocked or selectable the users are still able to cut the chart away from the sheet.
Assigning a macro to the chart also doesn’t solve the problem as I haven’t found a way to find out what chart has been clicked (and if possible I would avoid having to write a separatate sub for each chart..).
I’ve tried using the
Chart1_BeforeDoubleClick event but I can’t get it to work (does it only work in a chart worksheet?)
You can assign a sub routine on that chart:
Private Sub Chart1_Click() ActiveSheet.ChartObjects(1).CopyPicture MsgBox "Chart copied." End Sub
Since you’re going to use it on multiple charts, you need to identify the name of the chart first:
Sub Chart_Click() Dim chartName As String chartName = ActiveSheet.Shapes(Application.Caller).Name ActiveSheet.ChartObjects(chartName).CopyPicture MsgBox "Chart copied." End Sub