Microsoft KB Archive/278575

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

Article ID: 278575

Article Last Modified on 3/16/2007

-

APPLIES TO


 * Microsoft Office PowerPoint 2007
 * Microsoft Office PowerPoint 2003
 * Microsoft PowerPoint 2002 Standard Edition

-



This article was previously published under Q278575





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:  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.  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(&quot;Oval 4&quot;).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(&quot;Oval 4&quot;).Select ActiveWindow.View.GotoSlide Index:=ActivePresentation.Slides.Add(Index:=2, Layout:=ppLayoutText).SlideIndex End Sub   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  In the Visual Basic Editor window, click Run Sub/UserForm on the Run menu. 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.</ol>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

<div class="moreinformation_section">

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.
 * 1) Delete the oval.
 * 2) On the Tools menu, point to Macro, and then click Macros.
 * 3) In the Macro name list, click Test, and then click Run.

You receive the run-time error message that is mentioned in the &quot;Symptoms&quot; section.

PowerPoint 2007
In PowerPoint 2007, there is no Record New Macro command to directly record macros. To reproduce the problem, follow these steps: <ol> Start PowerPoint 2007.</li> On the Developer tab, click Visual Basic in the Code group to open the Visual Basic Editor.</li> Right-click VBAProject (Presentation1), point to Insert, and then click Module.</li>  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(&quot;Oval 4&quot;).Select ActiveWindow.View.GotoSlide Index:=ActivePresentation.Slides.Add(Index:=2, Layout:=ppLayoutText).SlideIndex End Sub </li> On the Run menu, click Run Sub/UserForm.

You receive the run-time error message that is mentioned in the &quot;Symptoms&quot; section.</li></ol>

Additional query words: PPT2002 PPT PPT2003 PPT2007

Keywords: kbbug kberrmsg kbfix KB278575

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.