macro to gray out cells

R

rockhammer

I have a table consisting of something like 32x45 cells that occupies pretty
much the whole of an 8.5"x11" page. Multiple distinct subsets of these cells
are merged. This table is further duplicated in multiple pages. The number of
pages with such a table is expected to grow over time.

What I want to do is to write a macro that will gray out the same
non-contiguous selection of cells in each of the identical tables in this
file.

I think I know the code to gray out a selection of cells. What i don't know
are:
1) for a specific table, how to establish the selection of non-contiguous
cells
2) how to write the loop that steps thru each of the tables consecutively

Thanks.
 
J

Jay Freedman

I have a table consisting of something like 32x45 cells that occupies pretty
much the whole of an 8.5"x11" page. Multiple distinct subsets of these cells
are merged. This table is further duplicated in multiple pages. The number of
pages with such a table is expected to grow over time.

What I want to do is to write a macro that will gray out the same
non-contiguous selection of cells in each of the identical tables in this
file.

I think I know the code to gray out a selection of cells. What i don't know
are:
1) for a specific table, how to establish the selection of non-contiguous
cells
2) how to write the loop that steps thru each of the tables consecutively

Thanks.

1) You cannot make a non-contiguous selection within a macro, regardless of
whether it's in a table or plain text. The article
http://support.microsoft.com/?kbid=288424 discusses this. You'll have to select
each contiguous piece, one at a time, to set its properties, then move on to the
next piece.

Also, VBA has trouble dealing with merged table cells. You may find that you
have to address some of the cells individually by row and column number.

2) Declare a Table object, and enclose all your manipulations within a loop like
this:

Dim oTbl As Table
For Each oTbl In ActiveDocument.Tables
' process oTbl.Cell(row, col) or other parts of oTbl
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top