Consulting

Results 1 to 9 of 9

Thread: Change color of only the selected shape in a group

  1. #1
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location

    Change color of only the selected shape in a group

    I use the following code to change the color of the selected shape to 100% black:

    Sub Black100()
    With ActiveWindow.Selection.ShapeRange
        .Fill.Visible = msoTrue
        .Fill.Solid
        .Fill.ForeColor.RGB = RGB(0, 0, 0)
        .Fill.Transparency = 0#
    End With
    End Sub
    But if the selected shape is part of a group, the whole group changes color. How can I modify this to only change the selected shape within that group?

    Your help is greatly appreciated!

    Cheryl

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    and no transparency are the defaults so:

    Sub groupy()
    On Error Resume Next
    If ActiveWindow.Selection.HasChildShapeRange Then
    With ActiveWindow.Selection.ChildShapeRange
    .Fill.ForeColor.RGB = RGB(0,0,0)
    End With
    End If
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location
    This is perfect! Thank you so much!

    Cheryl

  4. #4
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location
    Oh! One more question... how would I alter that macro to change the text color of just that one shape (leaving the background as is)?

  5. #5
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    You don't say what version of Office but this will work in most versions.

    Sub groupyText()    
    On Error Resume Next
        If ActiveWindow.Selection.HasChildShapeRange Then
        If ActiveWindow.Selection.ChildShapeRange(1).HasTextFrame Then
            With ActiveWindow.Selection.ChildShapeRange(1)
                .TextFrame.TextRange.Font.Color.RGB = RGB(255, 0, 0)
            End With
        End If
        End If
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  6. #6
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location
    Ok, so this works on shapes. Is it possible to do the same thing with selected parts of a chart? Change the fill/background color of only the selected plot area, chart area, data series, bar segment, etc.?

  7. #7
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Sadly it isn't. Charts do not have childshaperanges! I have had this discussion with MSFT several times - they should!! In Excel it is easy but not in PPT.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  8. #8
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location
    Ok thanks for letter me know. It would definately have been nice if it was possible to do.

  9. #9
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Trust me it's big problem for me too. Clients just don't believe it cannot be done.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

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