![]() |
|
#1
|
|||
|
|||
![]()
If the shading you want to change really is table cell shading, then (a) it is not .Font.Shading and (b) you can't use Range.Find to locate it. [There are three possible kinds of shading in a table cell, controlled by the dropdown in the Shading page of the Borders & Shading dialog: Text, Cell, and Table. In VBA each of them is addressed differently.]
This macro iterates through all the cells of each row of each table in the document and makes the change when it finds the proper color of Cell background shading. Code:
Sub test() Dim tbl As Table Dim rw As Row Dim cel As Cell For Each tbl In ActiveDocument.Tables For Each rw In tbl.Rows For Each cel In rw.Cells If cel.Shading.BackgroundPatternColor = RGB(225, 225, 153) Then cel.Shading.BackgroundPatternColor = RGB(225, 225, 225) End If Next cel Next rw Next tbl End Sub |
#2
|
|||
|
|||
![]()
Thank you. I know it wants to work, but, Dag nabbit, now I'm getting the attached Run-time error 5991.
I've researched it and can't figure out what code to put where. What I've seen looks something like this: Table table=Globals.ThisDocument.Tables[1]; Range range = table.Range; for (int i = 1; i <= range.Cells.Count; i++) { if(range.Cells[i].RowIndex == table.Rows.Count) range.Cells[i].Range.Text = range.Cells[i].RowIndex + ":" + range.Cells[i].ColumnIndex; } Any thoughts? Thanks so much, David |
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
epid011 | Word Tables | 2 | 05-15-2017 05:21 PM |
![]() |
ibs | Word Tables | 1 | 11-22-2016 06:31 PM |
How to change the font color of cell values | sky474 | Excel | 7 | 03-06-2014 09:15 AM |
Change Cell Color Based On % Complete | jrfoley3 | Project | 1 | 05-30-2013 05:24 AM |
![]() |
Triscia | Word VBA | 3 | 01-30-2013 04:18 PM |