Shapes: identifying different types (charts, textboxes, pictures e

D

David Macdonald

Since I use various shapes quite a lot so I use a form. I get the list of the
shapes on a sheet very simply:
For Each Shape In ActiveSheet.Shapes
ListBox1.AddItem (Shape.name)
Next Shape
I have controls where I can set margins, add/modify alternative text and
shape names, convert Textboxes to Pictures etc.

Now the problem. My list contains all the TextBoxes, Charts, Rectangles,
Pictures and Ovals. And I noticed yesterday if I have any filters on, the
DropDowns are there too and create all sorts of trouble if I select them!
How can I filter the different types of Shape so my list will only show the
type I want? I'll use checkboxes I guess but what code can I use to recognise
a Picture from a chart or an activeX control from a yellow oval?

Thanks for any assistance.
 
P

Peter T

Dim shp As Shape
Dim shpType As MsoShapeType

'code

shpType = shp.Type
If shpType = msoFormControl Then
If TypeName(shp.DrawingObject) = "DropDown" Then
'probably a filter arrow
Else
' a Forms control
Elseif

There are (from memory) 17 shapeTypes, maybe use Select case to group
similar types.

Regards,
Peter T
 
J

Joel

the way I usally solve this problem is with the code below. The type will
tell you what the object is. YOu can also get the oleboject fro the shape.


Sub shapes()

For Each Shape In ActiveSheet.shapes
MsgBox (Shape.Name & " : " & Shape.Type)
If Shape.Type = msoOLEControlObject Then
Set obj = ActiveSheet.OLEObjects(Shape.Name)
End If
Next Shape

End Sub
 

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

Top