VBa adding slide title

M

mcambrose

I can manually add a title to a slide in outline view. If I then go into VBA
I can change this title using

myDocument.Shapes.Title.TextFrame.TextRange.Text = "My first Slide"

If my slide doesn't already have a title, then I get an error from the
statement above. I can't figure out how to add a title to a slide that
doesn't already have one. It seems that a title has to do with a shape, but I
can't identify one specific shape that is always the title shape. Any
suggestions or explanations why this can't easily be done is appreciated.
DOesn't seem like it should be very hard. I do know how to loop through the
shapes if there is something I need to do there.
 
L

Luca Brasi

Have a look at the "HasTitle" and the "Title" properties in the VBA help. See
the examples there. They should fit your needs.
Luca
 
M

mcambrose

THanks Steve. I tried this,but the following lines of code give an error. I
followed a suggestion given by the second response to my question and it
mentioned looking at hastitle property and the code suggest had a test to
make sure the layout wasn't ppplayoutBlank. This made me assume that the
reason your code didn't work is that I had the wront type of layout. I tried
to change it to pplayoutMixed and retry your code, but I get an error trying
to set the layout to pplayoutmixed. Thanks for any additional insight.

.Layout = .Layout
 
M

mcambrose

I changed the slide layout in code to title only and then ran steve's code.
Works great. You just need to be aware that there is not a title property on
slides with blank layout. Thank Stev ad all for the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top