Consulting

Results 1 to 5 of 5

Thread: Copying text font color from first cell to all cells in a table row

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Nov 2017
    Posts
    3
    Location

    Copying text font color from first cell to all cells in a table row

    Hi, I have a powerpoint presentation and each slide has a table

    for each row in the table, I want to copy the color of the text in the first cell to all cells in the same row
    this is the code but it just does not do anything

    thank you

    Sub ChangeColor(sStart As Integer, sEnd As Integer)
       Dim sColor As Long
       Dim oSld As Slide
       Dim oShp As Shape
       Dim oRow As Row
       Dim oCell As Cell
       Dim x As Long
       Dim oColor As Long
        
        With ActivePresentation
         For I = sStart To sEnd + 1
               Set oSld = ActivePresentation.Slides(I)
                   For Each oShp In oSld.Shapes
                       If oShp.HasTable Then
                           For Each oRow In oShp.Table.Rows
                               For Each oCell In oRow.Cells
                                   If oCell.Shape.TextFrame.HasText Then
                                      With oCell.Shape.TextFrame.TextRange
                                               For x = 1 To .Runs.Count
                                                      If x = 1 Then
                                                         oColor = .Runs(x).Font.Color.RGB
                                                      Else
                                                         .Runs(x).Font.Color.RGB = oColor
                                                     End If
                                              Next x
                                      End With
                                      End If 'has text
                                  Next oCell
                            Next oRow
                         End If
                        Next oShp
         Next I
    End With
    End Sub
    Last edited by SamT; 11-08-2017 at 04:58 PM.

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
  •