
Signature
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
Greg,
If I comment out your "If" test, it shades every cell in my 'virgin' test
table with three middle cells merged vertically?
And msgbox activedocument.tables(1).range.cells.count returns an accurate
cell count after merging.
Are you merging cells after a shading is applied and that is skewing the
background shading "If" test? Like the font property undefined code 999...?
Sub Test()
Dim oCell As Word.Cell
Dim oTbl As Word.Table
For Each oTbl In ActiveDocument.Tables
For Each oCell In oTbl.Range.Cells
' If oCell.Shading.BackgroundPatternColor = RGB(229, 170, 91) Then
oCell.Shading.BackgroundPatternColor = RGB(93, 143, 86)
'End If
Next
Next
End Sub
> If I create an table and add some cell specific shading then I can run this
> code to change the shading:
[quoted text clipped - 19 lines]
>
> Thanks.

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
Russ - 18 Nov 2007 20:31 GMT
Greg,
Experimenting further, I was able to duplicate the problem when rows
contained both vertical and horizontal merged cells. I put a message box
line and a oCell.Select line in the loop and I always saw the msgbox text
but some cells didn't become selected or shaded.
I tried to use range and that seemed to work.
For example:
oCell.Range.Shading.BackgroundPatternColor = RGB(93, 143, 86)
So it appears that the range object works better than the 'default'
selection object in this situation.
> Greg,
> If I comment out your "If" test, it shades every cell in my 'virgin' test
[quoted text clipped - 39 lines]
>>
>> Thanks.

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
Greg Maxey - 18 Nov 2007 23:39 GMT
Russ,
Thanks for working that out.

Signature
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
> Greg,
> Experimenting further, I was able to duplicate the problem when rows
[quoted text clipped - 53 lines]
>>>
>>> Thanks.