Consulting

Results 1 to 3 of 3

Thread: Change colour of specific shape on 1 slide (not all slides)

  1. #1

    Change colour of specific shape on 1 slide (not all slides)

    Hi,
    I am new to VBA and looking for some assistance on a code to change the colour of a specific shape on a powerpoint slide (but not all slides - just the active slide I am on). The current shape is a ShapeSnipRectangle (Left:=515, Top:=0, Width:=205, Height:=80) and is coloured RGB(255, 255, 102).

    I have the below code but this changes all shapes in all slides not just the current slide.

    Sub Slide_Updated()
       Dim oSh As Shape
       Dim oS1 As Slide
       For Each oS1 In ActivePresentation.Slides
           For Each oSh In oS1.Shapes
               If oSh.Fill.ForeColor.RGB = RGB(255, 255, 102) Then
                   oSh.Fill.ForeColor.RGB = RGB(179, 222, 104)
               End If
           Next oSh
       Next oS1
    End Sub
    Thanks,
    Jack.
    Last edited by Bob Phillips; 12-31-2015 at 04:15 AM. Reason: Added VBA tags

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Is this what you are looking for?

    Sub Slide_Updated()
    Dim oSh As Shape
    Dim oS1 As Slide
    Dim idx As Long
    
        idx = ActiveWindow.View.Slide.SlideIndex
        With ActivePresentation.Slides(idx)
            With .Shapes("myShape")
                If .Fill.ForeColor.RGB = RGB(255, 255, 102) Then
                    .Fill.ForeColor.RGB = RGB(179, 222, 104)
                End If
            End With
        End With
    End Sub
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Or maybe

    Sub Slide_Updated()   
    
    Dim osld As Slide
       Dim oshp As Shape
       Set osld = ActiveWindow.Selection.SlideRange(1)
       For Each oshp In osld.Shapes
          If oshp.Fill.ForeColor.RGB = RGB(255, 255, 102) Then
             oshp.Fill.ForeColor.RGB = RGB(179, 222, 104)
          End If
       Next oshp
    
    End Sub
    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
  •