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