Sub ApplyLayoutByIndex()
Dim sld As Slide
Dim shp As Shape
Dim xName As String
Set sld = Application.ActiveWindow.View.Slide
Dim xIndex As Integer
xName = "A final slide"
xIndex = getLayoutIndexByName(xName)
If xIndex = 0 Then
MsgBox "The layout name" & xName & "not found. Check the name of the layout", vbOKOnly
Exit Sub
End If
sld.CustomLayout = ActivePresentation.Designs(1).SlideMaster.CustomLayouts(xIndex)
End Sub
Function getLayoutIndexByName(xName As String) As Integer
ActivePresentation.Designs(1).SlideMaster.CustomLayouts.Item (1)
With ActivePresentation.Designs(1).SlideMaster.CustomLayouts
For i = 1 To .Count
If .Item(i).Name = xName Then
getLayoutIndexByName = i
Exit Function
End If
Next
End With
End Function
!