View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Nick Hebb Nick Hebb is offline
external usenet poster
 
Posts: 162
Default Strange Shapes.AddShape error

I have a function that gets called from the Worksheet_Change event.
Based on a set of conditions it adds a shape to the worksheet using a
function like this:

Set newShape = ws.Shapes.AddShape(shapeType, l, t, w, h)

where ws is a Worksheet object and shapeType is a msoAutoShapeType
variable.

In general it works fine. But while doing some testing I came across a
strange (to me) error. If I add a number of shapes to the worksheet,
then delete one, subsequent calls to this function raise an error.

The error is 434 - object required.

Here's the weirdness:
- The shape gets properly created
- Debug.Assert Not(ws is Nothing) checks out fine
- Debug.Assert Not(ws.Shapes is Nothing) checks out fine
- Debug.Print ws.Shapes.Count spits out the proper shape count before
and after the line.

So I'm not sure which 'object' it's referring to since they all seem to
be there and are visible is the Locals window when debugging.

Any ideas?

Thanks,

Nick Hebb