Selecting objects

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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
 
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
 
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
 
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
 

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