Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can I determine the active selection's type?

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default Can I determine the active selection's type?

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

"MartinS" wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Can I determine the active selection's type?

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

--
Regards,
Tom Ogilvy




"MartinS" wrote in message
oups.com...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Can I determine the active selection's type?

Hi,

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

MsgBox TypeName(Selection)

Cheers
Andy

MartinS wrote:
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


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Can I determine the active selection's type?

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



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
use active cell to determine range Gizmo Excel Discussion (Misc queries) 2 March 31st 08 04:55 AM
How to Determine if Application Window Still Active Edwin Kelly Excel Discussion (Misc queries) 3 June 26th 07 05:42 PM
Selection's first and last row Tim Coddington Excel Programming 2 November 2nd 04 03:18 PM
Determine File Type Brent[_5_] Excel Programming 2 January 6th 04 06:43 AM
Determine active file size pk Excel Programming 1 October 27th 03 03:46 PM


All times are GMT +1. The time now is 02:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"