RogChele
11-27-2016, 04:59 PM
I was given a presentation with a slide master that has been formatted to their specification. Since I am new to VBA in powerpoint, I have been struggling with a particular task.
Goal:
- create a macro that changes the current text placeholder to "Internal use" in the footer of the powerpoint in the Slide Master.
The actual "footer" is used for title of the presentation so I will assume that the box I am trying to change is the placeholder?
- once the text has been changed, I would like to modify the font, font size, and color.
- Next macro I am trying to create, searches for the placeholder with "Internal Use" and replaces it with "Strictly Confidential" .
- once the new text has been inserted, I want to modify the font color.
- I need the ability to run a macro that will allow me to constantly change back and forth from "Internal Use" to "Confidential" based on the audience.
- with this change it needs to be reflected in the actual presentation slides.
Problem:
- I have google for solutions and I am having a hard time specifying if the current "Internal Use" text is a textbox or placeholder.
- I have written the code to name the "box" as a footer and as a placeholder (not sure what I am doing wrong)
- I at one point figured out a way to make the text change in the slide master but it did not impact the actual presentation (and I need it to)
- I have attempted to add a text placeholder (onthe master slide) but that area of the powerpoint is greyed out.
1st Attempt:
Below is a copy of a code I was assisted with but my problem is its referencing slides when I believe I need to reference the slide master? And lastly, I believe they are trying to take the "Internal Use" and change it to "Confidential" in the same macro and its not working.
Sub footers()
Dim osld As Slide
Dim oCust As CustomLayout
'change this to the text needed
Const strFooter1 As String = "abc"
Const strFooter2 As String = "xyz"
'change master
With ActivePresentation.SlideMaster.HeadersFooters.Footer
Select Case .Text
Case strFooter2
.Text = strFooter1
Case strFooter1
.Text = strFooter2
End Select
End With
'change layouts
For Each oCust In ActivePresentation.SlideMaster.CustomLayouts
With oCust.HeadersFooters.Footer
Select Case .Text
Case strFooter2
.Text = strFooter1
Case strFooter1
.Text = strFooter2
End Select
End With
Next oCust
'change slides
For Each osld In ActivePresentation.Slides
With osld.HeadersFooters.Footer
.Visible = True
Select Case .Text
Case strFooter2
.Text = strFooter1
Case strFooter1
.Text = strFooter2
End Select
End With
Next osld
End Sub
2nd Attempt (found help online)
Sub My_Internal()
Dim oCust As CustomLayout
Dim oColl As New Collection
Dim oDes As Design
Dim oShp As Shape
Dim osld As Slide
ActivePresentation.SlideMaster.HeadersFooters.Footer.Visible = True
'create collection of footers in master and all layouts
'######################################################
For Each oDes In ActivePresentation.Designs
For Each oShp In oDes.SlideMaster.Shapes
If oShp.Type = msoPlaceholder Then
If oShp.PlaceholderFormat.Type = ppPlaceholderFooter Then
oColl.Add oShp
End If
End If
Next oShp
For Each oCust In oDes.SlideMaster.CustomLayouts
oCust.HeadersFooters.Footer.Visible = True
For Each oShp In oCust.Shapes
If oShp.Type = msoPlaceholder Then
If oShp.PlaceholderFormat.Type = ppPlaceholderFooter Then
oColl.Add oShp
End If
End If
Next oShp
Next oCust
Next oDes
'######################################################
'set the footers
For Each oShp In oColl
With oShp.TextFrame.TextRange
.Text = "Strictly Confidential"
With .Font
.Name = "Arial"
.Size = 8
.Color.RGB = RGB(209, 0, 36)
End With
End With
Next oShp
For Each osld In ActivePresentation.Slides
With osld.HeadersFooters.Footer
.Visible = True
Select Case .Text
Case strFooter2
.Text = strFooter1
Case strFooter1
.Text = strFooter2
End Select
End With
Next osld
End Sub
All help is GREATLY appreciated. I have been working on this for several days and I am at a loss.
Thank you,
RogChele
Goal:
- create a macro that changes the current text placeholder to "Internal use" in the footer of the powerpoint in the Slide Master.
The actual "footer" is used for title of the presentation so I will assume that the box I am trying to change is the placeholder?
- once the text has been changed, I would like to modify the font, font size, and color.
- Next macro I am trying to create, searches for the placeholder with "Internal Use" and replaces it with "Strictly Confidential" .
- once the new text has been inserted, I want to modify the font color.
- I need the ability to run a macro that will allow me to constantly change back and forth from "Internal Use" to "Confidential" based on the audience.
- with this change it needs to be reflected in the actual presentation slides.
Problem:
- I have google for solutions and I am having a hard time specifying if the current "Internal Use" text is a textbox or placeholder.
- I have written the code to name the "box" as a footer and as a placeholder (not sure what I am doing wrong)
- I at one point figured out a way to make the text change in the slide master but it did not impact the actual presentation (and I need it to)
- I have attempted to add a text placeholder (onthe master slide) but that area of the powerpoint is greyed out.
1st Attempt:
Below is a copy of a code I was assisted with but my problem is its referencing slides when I believe I need to reference the slide master? And lastly, I believe they are trying to take the "Internal Use" and change it to "Confidential" in the same macro and its not working.
Sub footers()
Dim osld As Slide
Dim oCust As CustomLayout
'change this to the text needed
Const strFooter1 As String = "abc"
Const strFooter2 As String = "xyz"
'change master
With ActivePresentation.SlideMaster.HeadersFooters.Footer
Select Case .Text
Case strFooter2
.Text = strFooter1
Case strFooter1
.Text = strFooter2
End Select
End With
'change layouts
For Each oCust In ActivePresentation.SlideMaster.CustomLayouts
With oCust.HeadersFooters.Footer
Select Case .Text
Case strFooter2
.Text = strFooter1
Case strFooter1
.Text = strFooter2
End Select
End With
Next oCust
'change slides
For Each osld In ActivePresentation.Slides
With osld.HeadersFooters.Footer
.Visible = True
Select Case .Text
Case strFooter2
.Text = strFooter1
Case strFooter1
.Text = strFooter2
End Select
End With
Next osld
End Sub
2nd Attempt (found help online)
Sub My_Internal()
Dim oCust As CustomLayout
Dim oColl As New Collection
Dim oDes As Design
Dim oShp As Shape
Dim osld As Slide
ActivePresentation.SlideMaster.HeadersFooters.Footer.Visible = True
'create collection of footers in master and all layouts
'######################################################
For Each oDes In ActivePresentation.Designs
For Each oShp In oDes.SlideMaster.Shapes
If oShp.Type = msoPlaceholder Then
If oShp.PlaceholderFormat.Type = ppPlaceholderFooter Then
oColl.Add oShp
End If
End If
Next oShp
For Each oCust In oDes.SlideMaster.CustomLayouts
oCust.HeadersFooters.Footer.Visible = True
For Each oShp In oCust.Shapes
If oShp.Type = msoPlaceholder Then
If oShp.PlaceholderFormat.Type = ppPlaceholderFooter Then
oColl.Add oShp
End If
End If
Next oShp
Next oCust
Next oDes
'######################################################
'set the footers
For Each oShp In oColl
With oShp.TextFrame.TextRange
.Text = "Strictly Confidential"
With .Font
.Name = "Arial"
.Size = 8
.Color.RGB = RGB(209, 0, 36)
End With
End With
Next oShp
For Each osld In ActivePresentation.Slides
With osld.HeadersFooters.Footer
.Visible = True
Select Case .Text
Case strFooter2
.Text = strFooter1
Case strFooter1
.Text = strFooter2
End Select
End With
Next osld
End Sub
All help is GREATLY appreciated. I have been working on this for several days and I am at a loss.
Thank you,
RogChele