Shapes.ItemFromId gives shape even if id invalid

P

Phil Spiby

I have just found that ItemFromId will return a shape from a shapes
collection even if the id is invalid.
I expected this to thow an error, such as invalid sheet id or equivalent.

I guess my only re-course is to test the master of the returned shape, if it
is an invalid shape then it will throw the invalid sheet id error.
 
C

Chris Roth [ Visio MVP ]

I noticed that if you try to get *some* of the properties, you get errors
back. Name and NameU give you results, but Type and Text give errors, so
perhaps you can make a small function that wraps up ItemFromID in a somewhat
more reliable form.

--

Hope this helps,

Chris Roth
Visio MVP
 
P

Phil Spiby

Chris,

This is exactly what I decided to do. Since all my calls to this method were
from shapes collections, I have created a ShapeFromId function, in which I
try to access the master of the shape. If the shape is invalid then this
triggers the Invalid sheet identifier (-2032465756) error, which I then use
to reset the shape to nothing before returning.

Phil
 

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