"Requested object no available" - VB error

S

Smriti

Hi,

I get the error "Requested object not available" in VB
..NET. I've tried to find on the net but could get any
documentation on it.

I want to access the shapes, if any, present in a paragraph
of a word document. So I use
paragraphs(n).range.shaperange.count ,where n is any integer,
to check if there are any shapes in the paragraph. But if
the paragraph is just a newline then I get the above error.
I tried to do a check on it:
if not isnothing(range.shaperange)
....
end if
but that too gives the same error.

Could anybody please tell me where I could be going wrong ?

Thanks,
Smriti
 
M

mcalex

I don't 100% know coz _Word_ VBA is not my expertise, but I'd be
checking to see if a paragraph with just a newline can contain a
range, and if so, if that range can contain a shaperange.

hth
alex
 
P

Peter Hewett

Hi Smriti

I'm afraid you've hit another Word anomaly! When a range object does not have any Shapes,
for some reason Word does not assign anything to the ShapeRange Collection object. So you
always end up with a "Requested object not available" error.

The only thing you can do is to put that statement in a Try/Catch block and maybe test for
that specific error using a When clause.

HTH + Cheers - Peter
 

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