A
avkokin
Hello.
There is the table which has some cells with text into these cells,
e.g. "abcd". I need to fill of color only these cells. I did so:
Sub tablecolor()
'
Dim rngTable As Range
Dim oTable As Table
Dim oRow As Row
Dim oCell As cell
Set rngTable = Selection.Range
Set oTable = Selection.Tables(1)
If Not rngTable.Information(wdWithInTable) Then
MsgBox "You are not within the table"
Else
With oTable
For Each oRow In .Rows
For Each oCell In oRow.Cells
If .Range.Text = "abcd" Then
oCell.Shading.BackgroundPatternColor = wdColorBlueGray
End If
Next oCell
Next oRow
End With
End If
End Sub
But it not work. Why? How to fill of color of necessary cells?
Thank you.
There is the table which has some cells with text into these cells,
e.g. "abcd". I need to fill of color only these cells. I did so:
Sub tablecolor()
'
Dim rngTable As Range
Dim oTable As Table
Dim oRow As Row
Dim oCell As cell
Set rngTable = Selection.Range
Set oTable = Selection.Tables(1)
If Not rngTable.Information(wdWithInTable) Then
MsgBox "You are not within the table"
Else
With oTable
For Each oRow In .Rows
For Each oCell In oRow.Cells
If .Range.Text = "abcd" Then
oCell.Shading.BackgroundPatternColor = wdColorBlueGray
End If
Next oCell
Next oRow
End With
End If
End Sub
But it not work. Why? How to fill of color of necessary cells?
Thank you.