PowerPoint VBA - turn fill color of Text to No Fill

hindersaliva
hindersaliva used Ask the Experts™
on
I have Titles on my PowerPoint slides so that they appear on the Outline. I don't want these Titles to appear on the presentation.

I need to programatically turn the Fill color of the text to No Fill. And back again to Black.

Can someone show me the VBA code for this please?

Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Fabrice LambertConsulting
Distinguished Expert 2017

Commented:
Can you provide a sample document ?
Senior Technical Consultant at BrightCarbon
Commented:
Try this:

Option Explicit

' ============================================================================
' PowerPoint macros to toggle the fill colour for all Titles in a presentation
' Author : Jamie Garroch, BrightCarbon (http://brightcarbon.com)
' Date : 15NOV2018
' ============================================================================

Public Sub TurnOnTitles()
  SwitchTitleFill True
  'SwitchTitleVisible True
End Sub

Public Sub TurnOffTitles()
  SwitchTitleFill False
  'SwitchTitleVisible False
End Sub

' Toggles the title placeholder font fill
Private Sub SwitchTitleFill(bVisible As Boolean)
  Dim oSld As Slide
  
  For Each oSld In ActivePresentation.Slides
    With oSld.Shapes.Title.TextFrame2.TextRange.Font
      If bVisible Then .Fill.ForeColor.RGB = vbBlack
      .Fill.Visible = bVisible
    End With
  Next
End Sub

' Toggles the title placeholder visible property
Private Sub SwitchTitleVisible(bVisible As Boolean)
  Dim oSld As Slide
  
  For Each oSld In ActivePresentation.Slides
    oSld.Shapes.Title.Visible = bVisible
  Next
End Sub

Open in new window


There are two alternative procedures for hiding the title placeholder. The first one does what you asked and the second one is simpler in that it just toggles the visible property, as used in the Alt+F10 Selection Pane.

Author

Commented:
That's perfect Jamie!
Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial