Hi
I'm trying to use VBA set the layout of the active slide (or any slide) to a custom layout.
I can achieve this by referring to the index number but can't get it to work if I try and refer to the name of the layout.
For example:
[vba]
Dim oSld As Slide
Set oSld = ActivePresentation.Slides(1)
Dim oLayout As CustomLayout
'This code will work
Set oLayout = ActivePresentation.Designs("Master").SlideMaster.CustomLayouts(3)
oSld.CustomLayout = oLayout
'But this code will not work
Set oLayout = ActivePresentation.Designs("Master").SlideMaster.CustomLayouts("InternalDiv ider")
oSld.CustomLayout = oLayout
'This code does not work either
Dim strLayout As String
strLayout = ActivePresentation.Designs("Master").SlideMaster.CustomLayouts(3).Name
Set oLayout = ActivePresentation.Designs("Master").SlideMaster.CustomLayouts(strLayout)
oSld.CustomLayout = oLayout
[/vba]
For the two layouts that don't work I keep getting the error message "CustomLayouts (unknown member): Bad argument type. Expected collection index (string or integer)."
Has anyone been able to refer to a customlayout by string?
I would like to refer to the CustomLayouts by name in case the end user decides to rearrange the order of layouts or delete my layout (in which case the error handling will tell them the layout doesn't exist and to reapply the template).
Thanks
Nick