Re: Macro to replace styles used in tables (Word 2000/Windows)

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Jezebel (madbastard_at_whitehouse.gov)
Date: 01/26/05


Date: Wed, 26 Jan 2005 15:36:18 +1100

The code might look something like this --

Dim pTable as Word.Table
Dim pCell as Word.Cell

For each pTable in ActiveDocument.Tables

    If pTable.Range.Information(wdActiveEndPageNumber) > 1 then

        Set pCell = pTable.Cell(1,1)

        Do
            If pCell.RowIndex = 1 then
                pCell.Range.Style = "TableHead"
            Else
                pCell.Range.Style = "TableText"
            End if

            Set pCell = pCell.Next

        Loop until pCell is nothing
    End if

Next

<YEIREZQVBHEY@spammotel.com> wrote in message
news:1106709505.643254.144910@c13g2000cwb.googlegroups.com...
> Hello,
>
> While I have a pretty good grasp on recording macros, when it comes to
> doing something like actual programming, I am in over my head!
>
> I have found various code snippets in the groups and have tried to make
> modifications, but haven't been particularly successful in my quest.
> Here's what I'm trying to do:
>
> I want to modify every table (and only tables) in a document so that
> the first row is set to a particular style (TableHead), and all
> remaining rows are set to another particular style (TableText).
>
> Okay, that's not completely accurate. I do want to exclude the table on
> the first page as well as the tables in the headers from this style
> replacement.
>
> The number of tables in the documents I need to modify can range from
> no tables (other than the one on the first page and in the headers) or
> up to 60 tables. The number of rows and columns will vary from table to
> table and document to document. The same holds true for the styles
> currently being used in the tables.
>
> Currently working with Word 2000 for Windows running on Windows 2000.
> Any advice or help will be greatly appreciated!
>
> Dan
>


Quantcast