Help and Support

Article ID: 278575 - Last Review: March 16, 2007 - Revision: 2.1

Error message when you run a macro that is to insert an object into a slide in PowerPoint: "The item with the specified name wasn't found"

This article was previously published under Q278575

On This Page

Expand all | Collapse all

SYMPTOMS

In Microsoft PowerPoint, you record a macro that is to insert an object into a presentation slide, and then run the macro. When you do this, you may receive a run-time error message that resembles the following error message:
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, with Rectangles, with Ovals, with Text Boxes, with WordArt, with ClipArt, and with Pictures.

CAUSE

This problem occurs if the following actions occur when you record the macro:
  • You clear the selection of the object.
  • You reselect the object before you stop recording the macro.

WORKAROUND

To work around this problem, follow these steps:
  1. In Microsoft Office PowerPoint 2003 and in earlier versions of PowerPoint, point to Macro on the Tools menu, and then click Macros.

    In Microsoft Office PowerPoint 2007, click Macros on the Developer tab in the Code group.
  2. In the Macro name list, click Test, and then click Edit.

    In PowerPoint 2003 and in earlier versions of PowerPoint, the macro resembles the following macro.

    Note 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
    					
    In PowerPoint 2007, the macro resembles the following macro.

    Note The coordinates will vary.
    Sub Test()
        ActiveWindow.Selection.SlideRange.Shapes.AddShape(msoShapeOval, 192#, 54#, 222#, 132#).Select
        ActiveWindow.Selection.Unselect
        ActiveWindow.Selection.SlideRange.Shapes("Oval 4").Select
        ActiveWindow.View.GotoSlide Index:=ActivePresentation.Slides.Add(Index:=2, Layout:=ppLayoutText).SlideIndex
    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
    					
  4. In the Visual Basic Editor window, click Run Sub/UserForm on the Run menu.
  5. In the Macros dialog box, click Test, and then click Run.

    In the PowerPoint window, a shape is inserted into the slide, and you do not receive an error message.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to reproduce the problem

To reproduce the problem, follow these steps, as appropriate for the version of PowerPoint that you are running.

Microsoft PowerPoint 2002 or PowerPoint 2003

  1. Start PowerPoint.
  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 the 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.

    Notice that 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 that is mentioned in the "Symptoms" section.

PowerPoint 2007

In PowerPoint 2007, there is no Record New Macro command to directly record macros. To reproduce the problem, follow these steps:
  1. Start PowerPoint 2007.
  2. On the Developer tab, click Visual Basic in the Code group to open the Visual Basic Editor.
  3. Right-click VBAProject (Presentation1), point to Insert, and then click Module.
  4. Add the following code in the Module1(Code) window to create a new slide and to add a shape.
    Sub Test()
        ActiveWindow.Selection.SlideRange.Shapes.AddShape(msoShapeOval, 192#, 54#, 222#, 132#).Select
        ActiveWindow.Selection.Unselect
        ActiveWindow.Selection.SlideRange.Shapes("Oval 4").Select
        ActiveWindow.View.GotoSlide Index:=ActivePresentation.Slides.Add(Index:=2, Layout:=ppLayoutText).SlideIndex
    End Sub
    
  5. On the Run menu, click Run Sub/UserForm.

    You receive the run-time error message that is mentioned in the "Symptoms" section.

APPLIES TO
  • Microsoft Office PowerPoint 2007
  • Microsoft Office PowerPoint 2003
  • Microsoft PowerPoint 2002 Standard Edition
Keywords: 
kbbug kberrmsg kbfix KB278575

Article Translations