Help With VB code

R

Ray Batig

Greetings,

I just started to write VB code for Powerpoint. The following code hides the
titles on all the slides.

Sub HideSlideTitles()
' Hides slide title by hiding the shape

Dim oSlide As Slide

For Each oSlide In ActiveWindow.Presentation.Slides
oSlide.Shapes.Title.Visible = msoFalse
Next oSlide

End Sub


The question is how do I skip the first slide which is the presentation
title page.

Any help or ideas are appreciated!

Thanks in advance!
 
S

Shyam Pillai

Ray,

Sub HideSlideTitles()
' Hides slide title by hiding the shape

Dim oSlide As Slide

For Each oSlide In ActiveWindow.Presentation.Slides
' Does the shape have a title?
If oSlide.Shapes.HasTitle Then
'If it is not a title slide then hide the title.
If oSlide.Layout <> ppLayoutTitle Then
oSlide.Shapes.Title.Visible = msoFalse
End If
End If
Next oSlide

End Sub


--
Regards,
Shyam Pillai

Animation Carbon
http://www.animationcarbon.com
 
B

Bill Dilworth

I would try something like this.


Sub HideUnwantedSlideTitles()
' Hides slide title placeholder on _
non-TitleMaster slides

Dim x As Integer

For x = 2 To ActivePresentation.Slides.Count
With ActivePresentation.Slides(x)
If .Layout <> ppLayoutBlank And _
.Layout <> ppLayoutTitle And _
.Layout <> ppLayoutTitleOnly Then
.Shapes.Title.Visible = msoFalse
End If
End With
Next x

End Sub

--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
vestprog2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 
G

Guest

Hi Bill

Shyam's code will do what you need if you want to not rempve the titles from
title layout slides (this is often slide 1, but not always)

There are errors in your code (corrected by Shyam) which I thought I would
point out in the interests of education! If you do not check that the slide
has a title

"If oSlide.Shapes.HasTitle Then " ....

any slide without a title will crash the code and can put the user into the
vb editor which is NOT a good idea! Bill checks this in a different way by
checking for blank layout (which doesn't have a title placeholder). Even with
Bill's check the code will crash if the title placeholder has been deleted
from another layout.

-- Improve your skills - http://www.technologytrish.co.uk/ppttipshome.html
email john AT technologytrish.co.uk


Need a dice throw for a ppt game?- http://www.technologytrish.co.uk/dice.html
 

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