Can I determine the active selection's type?

  • Thread starter Thread starter MartinS
  • Start date Start date
M

MartinS

Hi
I am attempting to add some error handling to a process that allows the
user to save the active chart as an image. The first thing the process
does is request a filename, and at the moment I have added in an 'On
Error Goto' command to skip the rest of the code. My question is this
- is it possible to find out what the current selected object type is
and if not a chart then invoke an error? For example, if the user had
simply selected a cell, and not a chart object, it would not ask for a
filename but give the user an error message, whereas if the user had
correctly selected a chart object (either on a chart sheet or as an
object in a worksheet), it would proceed to ask for the filename to
save the image to.
I hope this makes sense - I don't think it's easy, but also not
convinced that its not doable, so if anyone has a way to do this, I'd
be most grateful.
Regards
Martin
 
my only suggestion is to try to use a property that is unique to a chart
selection.charttype if it returns an error that it is not a chart
 
If I select an embedded chart in a worksheet and test in the immediate
window:

? typename(selection)
ChartArea

so

if TypeName(Selection) <> "ChartArea" then
Exit sub
End if
 
Hi,

Try using the TypeName() function. Should tell you what is active.

MsgBox TypeName(Selection)

Cheers
Andy
 
Hi
Thanks - that's just what I needed. I guess I was assuming it would be
harder than that so hadn't even considered using TypeName.
Excellent - thanks again
Regards
Martin
 

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