Consulting

Results 1 to 15 of 15

Thread: Change Placeholder text from "Internal Use" to "Confidential"

  1. #1
    VBAX Regular
    Joined
    Nov 2016
    Posts
    12
    Location

    Change Placeholder text from "Internal Use" to "Confidential"

    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

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Try this:

    Sub FooterFix()
    Dim osld As Slide
    Dim ofoot As Shape
    Dim ocust As CustomLayout
    Dim strfoot As String
    For Each osld In ActivePresentation.Slides
    osld.HeadersFooters.Footer.Visible = True
    Set ofoot = getFooter(osld)
    Select Case UCase(ofoot.TextFrame2.TextRange)
    Case Is = "INTERNAL USE", ""
    strfoot = "Confidential"
    Case Is = "CONFIDENTIAL"
    strfoot = "Internal Use"
    End Select
    Call addText(ofoot, strfoot)
    Next osld
    For Each ocust In ActivePresentation.Designs(1).SlideMaster.CustomLayouts
    Set ofoot = getFooter(ocust)
    Call addText(ofoot, strfoot)
    Next ocust
    Set ofoot = getFooter(ActivePresentation.Designs(1).SlideMaster)
    Call addText(ofoot, strfoot)
    End Sub
    
    
    Function getFooter(obj As Object) As Shape
    For Each getFooter In obj.Shapes
    If getFooter.Type = msoPlaceholder Then
    If getFooter.PlaceholderFormat.Type = ppPlaceholderFooter Then Exit Function
    End If
    Next
    End Function
    
    
    Sub addText(ofoot As Shape, strfoot As String)
    With ofoot.TextFrame2.TextRange
    .Text = strfoot
    .Font.Fill.ForeColor.RGB = RGB(209, 0, 36)
    .Font.Name = "Arial"
    .Font.Size = 8
    End With
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Regular
    Joined
    Nov 2016
    Posts
    12
    Location
    Of the following code, it gave me a runtime 91 error message on the line in quotes:
    "Select Case UCase(ofoot.TextFrame2.TextRange)"

    Error Message:
    ofoot.textframe2.textrange = <Object variable or With block variable not set>

    but the object variable "ofoot" has already been referenced

    Joy RogChele
    Last edited by RogChele; 11-28-2016 at 08:56 AM. Reason: clarification on error

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    You would get that error if the slide / master did not have a footer placeholder

    Sub FooterFix()
       Dim osld As Slide
       Dim ofoot As Shape
       Dim ocust As CustomLayout
       Dim strfoot As String
       For Each osld In ActivePresentation.Slides
          osld.HeadersFooters.Footer.Visible = True
          Set ofoot = getFooter(osld)
          If Not ofoot Is Nothing Then
             Select Case UCase(ofoot.TextFrame2.TextRange)
             Case Is = "INTERNAL USE", ""
                strfoot = "Confidential"
             Case Is = "CONFIDENTIAL"
                strfoot = "Internal Use"
             End Select
             Call addText(ofoot, strfoot)
          End If
       Next osld
       For Each ocust In ActivePresentation.Designs(1).SlideMaster.CustomLayouts
          Set ofoot = getFooter(ocust)
          If Not ofoot Is Nothing Then Call addText(ofoot, strfoot)
       Next ocust
       Set ofoot = getFooter(ActivePresentation.Designs(1).SlideMaster)
       If Not ofoot Is Nothing Then Call addText(ofoot, strfoot)
    End Sub
     
     
    Function getFooter(obj As Object) As Shape
        For Each getFooter In obj.Shapes
            If getFooter.Type = msoPlaceholder Then
                If getFooter.PlaceholderFormat.Type = ppPlaceholderFooter Then Exit Function
            End If
        Next
    End Function
     
     
    Sub addText(ofoot As Shape, strfoot As String)
        With ofoot.TextFrame2.TextRange
            .Text = strfoot
            .Font.Fill.ForeColor.RGB = RGB(209, 0, 36)
            .Font.Name = "Arial"
            .Font.Size = 8
        End With
    End Sub
    Also if you have a very early version TextFrame2 will cause an error. Say which version you have
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    VBAX Regular
    Joined
    Nov 2016
    Posts
    12
    Location
    I have PowerPoint 2016 and I checked the Master Layout and Footer was not checked.
    I checked the Footer and then inserted the "Internal Use" and saved.
    When I ran the code, it deleted "Internal Use" and now just says Footer.

    If the Footer box was not checked in the master layout, does that mean the text in the footer layouts are textboxes/created placeholders?


    Deep Desire to Learn,
    Thank you,

    Joy RogChele

  6. #6
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Probably. You would need to post a presentation to be sure. Are you able to edit the footers on the actual slides? Another possibility is it was originally created in version 2003 or earlier which has a different footer method.

    If you can post a few slides somewhere it will help.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  7. #7
    VBAX Regular
    Joined
    Nov 2016
    Posts
    12
    Location
    I checked and the powerpoint was originally created in 2013 and I am using 2016 version (problem 1)
    The "Internal Use" text was just text, not a footer, not a placeholder, and not a textbox (problem 2)

    I have now created a textbox (textbox1) through the developer tab. I entered the name through the properties option.
    If I try to edit the code above, instead of SUB it revises to PRIVATE SUB

    I am now getting a Compile Error - which I know is because I tried to Dim Box as Textbox1 (tried it as shape, still not working)

    It is where you would have had ofoot as Shape.

    PHP Code:
    Private Sub TxtFoot_Change()
    Dim Textbox1 As Shape
    Dim sld 
    As Slide
    Dim StrText 
    As String
    Dim ocust 
    As CustomLayout
    For Each sld In ActivePresentation.SlideMaster
    sld
    .Master.Textbox1.Visible True
    Set Box 
    getFooter(sld)
    If 
    Not Box Is Nothing Then
                Select 
    Case UCase(Textbox1.TextFrame2.TextRange)
                Case 
    Is "FOR INTERNAL USE ONLY"""
                    
    strfoot "Confidential"
                
    Case Is "CONFIDENTIAL"
                    
    strfoot "For Internal Use Only"
                
    End Select
                Call addText
    (Boxstrfoot)
            
    End If
        
    Next sld
        
    For Each ocust In ActivePresentation.Designs(1).SlideMaster.CustomLayouts
            Set Box 
    getFooter(ocust)
            If 
    Not Box Is Nothing Then Call addText(Boxstrfoot)
        
    Next ocust
        Set Box 
    getFooter(ActivePresentation.Designs(1).SlideMaster)
        If 
    Not Box Is Nothing Then Call addText(Boxstrfoot)
    End Sub
     
    Function getFooter(obj As Object) As Shape
        
    For Each getFooter In obj.Shapes
            
    If getFooter.Type msoPlaceholder Then
                
    If getFooter.PlaceholderFormat.Type ppPlaceholderFooter Then Exit Function
            
    End If
        
    Next
    End 
    Function
     
     
    Sub addText(Box As Shapestrfoot As String)
        
    With Box.TextFrame2.TextRange
            
    .Text strfoot
            
    .Font.Fill.ForeColor.RGB RGB(209036)
            .
    Font.Name "Arial"
            
    .Font.Size 8
        End With
    End Sub 

  8. #8
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    This is not meant to be judgemental but you are just creating problems for yourself. It is much harder to work with activX textboxes and you are going to struggle with your level of knowledge. Post a slide or two somewhere. If you use the advanced tab you can attach a sample here. If they really used an ActivX textbox (which is not smart) the code will be quite different.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  9. #9
    VBAX Regular
    Joined
    Nov 2016
    Posts
    12
    Location
    You are far from being judgemental!! I know I am VERY new at this and I am grasping some of the concepts but still run into issues (clearly).

    I have only been studying/learning how to do this for 1.5 weeks - I am more than appreciative for any feedback, criticism, helpful hints that I recieve.

    I have attached a template powerpoint that I have been testing on so I would not ruin the final project.

    The "cut off textbox" if what I created and yes it is ActiveX Control - and clearly that is bad lol (googling why now)

    Thank you for your patience and willingness to help me learn!
    Attached Files Attached Files

  10. #10
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Try this:

    Sub Updater()
    
    
    Dim ActiShape As Object
    ' be sure to get the name exactly correct
    Set ActiShape = ActivePresentation.Designs(1).SlideMaster.Shapes("TextBox1").OLEFormat.Object
    Select Case ActiShape.Text
    Case Is = "For Internal Use Only"
    ActiShape.Text = "Confidential"
    Case Is = "Confidential", ""
    ActiShape.Text = "For Internal Use Only"
    End Select
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  11. #11
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Try this: (with colour)

    Sub Updater()Dim ActiShape As Object
    ' be sure to get the name exactly correct
    Set ActiShape = ActivePresentation.Designs(1).SlideMaster.Shapes("TextBox1").OLEFormat.Object
    ActiShape.ForeColor = &H2400D1 
    'this is the color you mentioned in HEX!
    Select Case ActiShape.Text
    Case Is = "For Internal Use Only"
    ActiShape.Text = "Confidential"
    Case Is = "Confidential", ""
    ActiShape.Text = "For Internal Use Only"
    End Select
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  12. #12
    VBAX Regular
    Joined
    Nov 2016
    Posts
    12
    Location
    I revised the code below in an attempt to have the color of the text change based on the text itself.

    Strictly Confidential would be "&H2400D1"
    For Internal Use Only would be "&H808080"

    The font portion of the code works but not the name and forecolor portion.

    Sub Updater()
    Dim ActiShape As Object
    ' be sure to get the name exactly correct
    Set ActiShape = ActivePresentation.Designs(1).SlideMaster.Shapes("TextBox1").OLEFormat.Obje ct

    'ActiShape.ForeColor = &H2400D1
    'this is the color you mentioned in HEX!
    Select Case ActiShape.Text
    Case Is = "For Internal Use Only"
    ActiShape.Text = "Confidential"
    Case Is = "Confidential", ""
    ActiShape.Text = "For Internal Use Only"
    End Select

    With ActiShape
    .Text = "For Internal Use Only"
    With .Font
    .Name = "Arial"
    .Size = 9
    .ForeColor = &H808080
    End With
    End With

    With ActiShape
    .Text = "Strictly Confidential"
    With .Font
    .Name = "Arial"
    .Size = 9
    .ForeColor = &H2400D1
    End With
    End With
    End Sub

    Last edited by RogChele; 11-30-2016 at 02:10 PM. Reason: code clarification

  13. #13
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Maybe this:

    Sub Updater()
    Dim ActiShape As Object
         ' be sure to get the name exactly correct
        Set ActiShape = ActivePresentation.Designs(1).SlideMaster.Shapes("TextBox1").OLEFormat.Object
        ActiShape.Font.Name = "Arial"
        ActiShape.Font.Size = 8
         'this is the color you mentioned in HEX!
        Select Case ActiShape.Text
        Case Is = "For Internal Use Only"
            ActiShape.Text = "Confidential"
            ActiShape.ForeColor = &H2400D1
        Case Is = "Confidential", ""
            ActiShape.Text = "For Internal Use Only"
            ActiShape.ForeColor = &H2808080
        End Select
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  14. #14
    VBAX Regular
    Joined
    Nov 2016
    Posts
    12
    Location
    John,

    Thank you SO much. The code worked and I've revised it to include font variables such as Bold, Italicize, etc and it still works.

    Thank you again for your patience at my naivete and for all of your help!!!

    Last question for you.

    What is the most efficient way to learn VBA programming?

    Right now I have the Excel Bible as well as VBA for Dummies (Excel) because that is where my learning is focused (and I could not find anythign on Powerpoint specifically)

    I of course, test things out, fail, try again, google. etc.

    Any advise is appreciated.

    Joy

  15. #15
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    There is a PPT vba book "Powerful PowerPoint for Educators" by David Marcovitz.

    David is a friend and the book is useful especially for beginners.

    The only way to get in depth info is to study other code from experts and try to work out how it works. PowerPoint code is very different to Excel code.

    Places to look for good code

    http://www.pptalchemy.co.uk/powerpoi...tutorials.html (that's me)
    www.pptfaq.com Steve Rindsberg (he was my mentor!) Scroll to Programming
    http://skp.mvps.org/vba.htm#.WD_KOtWLS70 Shyam Pillai good for adnced topics
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •