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
 

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