'All these procedures run in Edit or Normal View, not SlideShow View 'This procedure returns the object name of the selected object 'in a MsgBox. It returns an error message if you have not selected 'an object or you have selected more than one object. Sub GetObjectName() If ActiveWindow.Selection.Type = ppSelectionShapes _ Or ActiveWindow.Selection.Type = ppSelectionText Then If ActiveWindow.Selection.ShapeRange.Count = 1 Then MsgBox (ActiveWindow.Selection.ShapeRange.Name) Else MsgBox ("You have selected more than one shape.") End If Else MsgBox ("No shapes are selected.") End If End Sub 'This procedure sets the name of an object to whatever you type. 'It returns an error message if you have not selected 'an object or you have selected more than one object. Sub SetObjectName() Dim objectName As String If ActiveWindow.Selection.Type = ppSelectionShapes _ Or ActiveWindow.Selection.Type = ppSelectionText Then If ActiveWindow.Selection.ShapeRange.Count = 1 Then objectName = InputBox(prompt:="Type a name for the object") objectName = Trim(objectName) If objectName = "" Then MsgBox ("You did not type anything. " & _ "The name will remain " & _ ActiveWindow.Selection.ShapeRange.Name) Else ActiveWindow.Selection.ShapeRange.Name = objectName End If Else MsgBox _ ("You can not name more than one shape at a time. " _ & "Select only one shape and try again.") End If Else MsgBox ("No shapes are selected.") End If End Sub 'The following procedures are just like the procedures above except that they 'do not check to make sure that you have one and only one object selected. Sub GetObjectNameNoError() MsgBox (ActiveWindow.Selection.ShapeRange.Name) End Sub Sub SetObjectNameNoError() Dim objectName As String objectName = InputBox(prompt:="Type a name for the object") objectName = Trim(objectName) If objectName = "" Then MsgBox ("You did not type anything. The name will remain " & _ ActiveWindow.Selection.ShapeRange.Name) Else ActiveWindow.Selection.ShapeRange.Name = objectName End If End Sub 'The following procedures are for getting and setting the names of slides. Sub GetSlideName() MsgBox ActiveWindow.View.Slide.Name End Sub Sub SetSlideName() Dim slideName As String slideName = InputBox(prompt:="Type a name for the slide") slideName = Trim(slideName) If slideName = "" Then MsgBox ("You did not type anything. " & _ "The name will remain " & _ ActiveWindow.View.Slide.Name) Else ActiveWindow.View.Slide.Name = slideName End If End Sub