Testing For Valid Collections

G

George Lee

How do you test if a collection is valid?
For example, for inline shapes the Count is always available, even if it's
zero. On other hand, ShapeRange will be "Requested object is not available"
if it's zero. How do you texst for that case?
 
J

Jezebel

Unfortunately, this is not something that the MS programmers handled
consistently. In some cases, you can use code like

If not [Object] is nothing then
...

But that doesn't always work (including with the ShapeRange). Or you can use
code like

Dim pIsValid as boolean
Dim pCount as long

on error resume next
pCount = ActiveDocumernt.Content.ShapeRange.Count
pIsValid = (Err.Number = 0)
on error goto 0
 
Top