![]() |
Selecting objects
If the user has multiple objects selected, I want to do something. If you
have one object selected, and use Selection.Name it gives the name of the object. If you have multiple objects selected, it gives an error. So I thought I could do this: If Selection.Name Is Error Then (do whatever) But it doesn't work. Any ideas? |
Selecting objects
Your trying to see if multiple objects are selected
Demo'd from the immediate window: ? selection.count 3 ? selection(1).Name Rectangle 6 ? selection(2).Name Oval 7 so use if selection.count 1 then ' multiple objects selected -- regards, Tom Ogilvy "Mike" wrote: If the user has multiple objects selected, I want to do something. If you have one object selected, and use Selection.Name it gives the name of the object. If you have multiple objects selected, it gives an error. So I thought I could do this: If Selection.Name Is Error Then (do whatever) But it doesn't work. Any ideas? |
Selecting objects
Seems easy enough, but does not seem to be working. I have this:
Selection.Count If Selection.Count 1 Then GoTo MultipleObjects Else End If Does not seem to understand Selection.Count "Tom Ogilvy" wrote: Your trying to see if multiple objects are selected Demo'd from the immediate window: ? selection.count 3 ? selection(1).Name Rectangle 6 ? selection(2).Name Oval 7 so use if selection.count 1 then ' multiple objects selected -- regards, Tom Ogilvy "Mike" wrote: If the user has multiple objects selected, I want to do something. If you have one object selected, and use Selection.Name it gives the name of the object. If you have multiple objects selected, it gives an error. So I thought I could do this: If Selection.Name Is Error Then (do whatever) But it doesn't work. Any ideas? |
Selecting objects
It won't understand selection.count if only one shape is selected. So:
Dim s as String on Error resume Next s = selection.Name On error goto 0 if s = "" then goto Multiple else ' only one selected end if -- regards, Tom Ogilvy "Mike" wrote in message ... Seems easy enough, but does not seem to be working. I have this: Selection.Count If Selection.Count 1 Then GoTo MultipleObjects Else End If Does not seem to understand Selection.Count "Tom Ogilvy" wrote: Your trying to see if multiple objects are selected Demo'd from the immediate window: ? selection.count 3 ? selection(1).Name Rectangle 6 ? selection(2).Name Oval 7 so use if selection.count 1 then ' multiple objects selected -- regards, Tom Ogilvy "Mike" wrote: If the user has multiple objects selected, I want to do something. If you have one object selected, and use Selection.Name it gives the name of the object. If you have multiple objects selected, it gives an error. So I thought I could do this: If Selection.Name Is Error Then (do whatever) But it doesn't work. Any ideas? |
Selecting objects
Mike,
If you are running this code from a button click, make sure its ..TakeFocusOnClick=False, otherwise you will always return a Selection.Count=1, i.e. the button. NickHK "Mike" wrote in message ... Seems easy enough, but does not seem to be working. I have this: Selection.Count If Selection.Count 1 Then GoTo MultipleObjects Else End If Does not seem to understand Selection.Count "Tom Ogilvy" wrote: Your trying to see if multiple objects are selected Demo'd from the immediate window: ? selection.count 3 ? selection(1).Name Rectangle 6 ? selection(2).Name Oval 7 so use if selection.count 1 then ' multiple objects selected -- regards, Tom Ogilvy "Mike" wrote: If the user has multiple objects selected, I want to do something. If you have one object selected, and use Selection.Name it gives the name of the object. If you have multiple objects selected, it gives an error. So I thought I could do this: If Selection.Name Is Error Then (do whatever) But it doesn't work. Any ideas? |
All times are GMT +1. The time now is 10:20 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com