Try Range.ShapeRange.Count
--
Enjoy,
Tony
> There's no Shapes collection from Range (you can get to InlineShapes but not
> Shapes). Shapes is accessed via the Document or Header/Footer objects only I
[quoted text clipped - 36 lines]
> > >> > --
> > >> > James
James was telling us:
James nous racontait que :
> From the Range object, you get a ShapeRange collection, but it doesn't
> contain any shapes! (I think ShapeRange only works properly from the
> Selection object). I've tried testing for an error on
Not so.
If I anchor two shapes to the first paragraph in the document, and then use:
Dim myParaRange As Range
Set myParaRange = ActiveDocument.Paragraphs(1).Range
MsgBox myParaRange.ShapeRange.Count
then I get "2" as expected.
If your ShapeRange collection returns 0, then it means there are no shape in
the range.
If you think there should be some, then either they are Inlineshapes, or you
did not set up your range properly.
> Range.ShapeRange.Anchor but the same error is generated if there are
> no shapes or if there are multiple shapes, so it's not reliable for
> what I want to do.
Anchor does not return the anchor itself, but allows you to access the
paragraph in which the Anchor is set.
Normally, we use it to access a paragraph range when we know/have access to
a shape anchored in an unspecified paragraph (Like the first shape in a
document, or access a shape by name)
E.g.
Dim myParaRange As Range
Set myParaRange = ActiveDocument.Shapes(1).Anchor.Paragraphs(1).Range
I thinmk if you start using the online help in the VB editor, you will save
yourself some time and be abler to go further on your own.
In the VB editor, ype
ActiveDocument.Paragraphs(1).ShapeRange(1).Anchor
then slect Anchor and hit F1.
You get:
<quote>
Anchor Property
See Also Applies To Example
Returns a Range object that represents the anchoring range for the specified
shape or shape range. Read-only.
<snip>
<\quote>
So, this tells me that
Dim myParaRange As Range
Dim myShapeTextRange As Range
Set myParaRange = ActiveDocument.Paragraphs(1).Range
Set myShapeTextRange = myParaRange.ShapeRange.Anchor
will fail because I do not specify which range I want from Anchor.
So, if I try
Dim myParaRange As Range
Dim myShapeTextRange As Range
Set myParaRange = ActiveDocument.Paragraphs(1).Range
Set myShapeTextRange = myParaRange.ShapeRange.Anchor.Paragraphs(1).Range
it also fails because I do not specify a particular shape.
This will work
Dim myParaRange As Range
Dim myShapeTextRange As Range
Set myParaRange = ActiveDocument.Paragraphs(1).Range
Set myShapeTextRange =
myParaRange.ShapeRange(1).Anchor.Paragraphs(1).Range

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Thanks guys
ShapeRange.Count is the solution - must have been defining the range wrongly
as you suggest

Signature
James
> There's no Shapes collection from Range (you can get to InlineShapes but not
> Shapes). Shapes is accessed via the Document or Header/Footer objects only I
[quoted text clipped - 30 lines]
> > >> >
> > >> > Thanks