View Single Post
 
Old 09-19-2014, 04:42 AM
QA_Compliance_Advisor QA_Compliance_Advisor is offline Windows 7 32bit Office 2010 32bit
Advanced Beginner
 
Join Date: Jul 2014
Posts: 44
QA_Compliance_Advisor is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
You need to identify the table the cells are in e.g.

Code:
Function ChangeLogo(wdDoc)
Dim oTable As Table
Dim ocell As Cell
    Set oTable = wdDoc.Tables(1)
    For Each ocell In oTable.Range.Cells
        With ocell.Shading
            If .BackgroundPatternColor = RGB(51, 51, 153) Then
                .BackgroundPatternColor = RGB(12, 71, 157)
                .ForegroundPatternColor = wdColorWhite
            End If
        End With
    Next ocell
End Function

I did it this way? any thoughts?

Code:
Function ChangeLogo(wdDoc)
Dim oCell As Cell, oTbl As Table, oRow As Row, oRng As Range
Dim i As Long
For Each oTbl In wdDoc.Tables
  For Each oRow In oTbl.Rows
    For Each oCell In oRow.Cells
      If oCell.Shading.BackgroundPatternColor = RGB(51, 51, 153) Then
      oCell.Shading.BackgroundPatternColor = RGB(12, 71, 157)
      End If
    Next
   Next
 Next
  
End Function
having troubles changing the text colour in the cell. Any suggestions?
Reply With Quote