ThisChart function similar to ThisWorkbook (XL2003)

  • Thread starter Thread starter markdayton
  • Start date Start date
M

markdayton

Is there a way to programatically determine a chart object's name when
it's not active? ThisWorkbook provides access to the name of the
workbook that contains the code without it having to be the active
workbook. I would like to be able to get the name of the chart object
that contains the macro code even when it's not the active chart.

I have a macro that I want to use as a template to copy to a chart
object's code page that will only run if that chart is active. I'm
trying to get around having to change the chart name in the code every
time I copy it to a new chart object.
 
'ThisWorkbook' is just the default code name for the Workbook object. It
rarely works in my applications because I change it to something more
meaningful.

If the code exists in the Chart sheet's code module, you can use "Me"

Private Sub Chart_Activate()
MsgBox Me.Name
End Sub
 
That's exactly what I needed. I thought that "Me" was for within Class
definitions.
 
The chart sheet's code module is essentially a class module. You can use Me
in a workbook or worksheet code module as well.

- Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top