PPT2002: Macro Run-Time Error: The Item with the Specified Name Wasn't Found (278575)



The information in this article applies to:

  • Microsoft PowerPoint 2002

This article was previously published under Q278575

SYMPTOMS

In Microsoft PowerPoint, when you record a macro to insert an object into a presentation slide, and you then run the macro, you may receive a run-time error message similar to the following:
The item with the specified name wasn't found.
When you click End on the error message, the object appears as expected.

This behavior occurs with AutoShapes, Rectangles, Ovals, Text Boxes, WordArt, ClipArt, and Pictures.

CAUSE

This behavior can occur if you create a macro to insert an object, but as part of the recording, you clear your selection of, and then reselect, the object before you stop recording the macro, as in the following example:
  1. Start PowerPoint, and then accept the default presentation.
  2. On the Tools menu, point to Macro, and then click Record New Macro.
  3. Type Test in the Macro name box, and then click OK.
  4. On the Drawing toolbar, click Oval.
  5. Draw an oval on the slide.
  6. Click outside the oval to clear your selection of the oval.
  7. Click to reselect the oval.
  8. On the Tools menu, point to Macro, and then click Stop Recording.
  9. On the Insert menu, click New Slide.
  10. On the Tools menu, point to Macro, and then click Macros.
  11. In the Macro name list, click Test, and then click Run.

    The oval appears as expected.
  12. Delete the oval.
  13. On the Tools menu, point to Macro, and then click Macros.
  14. In the Macro name list, click Test, and then click Run.

    You receive the run-time error message described in the "Symptoms" section.

WORKAROUND

To work around the behavior, follow these steps:
  1. On the Tools menu, point to Macro, and then click Macros.
  2. In the Macro name list, click Test, and then click Edit.

    The macro is currently similar to the following (note that the coordinates will vary):
    Sub Test()
       ActiveWindow.Selection.SlideRange.Shapes.AddShape(msoShapeOval, 246#, 198#, 210#, 228#).Select
       ActiveWindow.Selection.Unselect
       ActiveWindow.Selection.SlideRange.Shapes("Oval 4").Select
    End Sub
    					
  3. Edit the macro so that it reads as follows:
    Sub Test()
       ActiveWindow.Selection.SlideRange.Shapes.AddShape(msoShapeOval, 246#, 198#, 210#, 228#).Select
       'grab the name of the shape just created
       strName = ActiveWindow.Selection.ShapeRange.Name
       ActiveWindow.Selection.Unselect
       'select that shape using the NEW name
       ActiveWindow.Selection.SlideRange.Shapes(strName).Select
    End Sub
    					

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

Modification Type:MajorLast Reviewed:7/12/2001
Keywords:kbbug kberrmsg KB278575