AddTitle method works for slides with deleted title template. It fails for slide layouts that do not provide title: blank or largeobject.
In that case change of layout is required (dim ppSlide as Slide):
Code:
Set ppSlide=shSource.Parent
if ppSlide.Layout=ppLayoutBlank Then ppSlide.Layout=ppLayoutTitleOnly
You have to test for Layout=ppLayoutLargeObject too.
After the change of layout, title template is added. It is usually blank, but can contain text if previous (blank) layout was converted from a slide with title.
You need to take all this into account before applying above code. Title shape should be deleted if empty or left if already contains a title.
In practice you could, taking the above code is a starting point and using powerpoint vba help:
- test for layout, if necessary, change to containing title,
- select shape you want to convert to title, and:
- do nothing if slide has no empty title,
- create a title shape if there is no title,
- copy shape's contents and formatting to title and delete source shape.
For future work, the presentation's author could change the presentation layout. In general, you will not be able to fully automate the work as long as there are no clear condition to recognise shape to be converted to title.
combo