PDA

View Full Version : Solved: Styles in a table



crowfan
08-28-2007, 12:29 PM
Hello,

I am trying to write a macro that will apply two specific styles to a table. The first row should be set to style "TableHeading" and the rest of the rows should be set to "TableText." There are a *ton* of different styles that appear in these tables originally, and the goal is to convert them all to TableText (and TableHeading, where appropriate).

So far I have written a macro that selects the table, applies the "TableText" style to the whole table, and then applies the "TableHeading" style to the first row.

The problem is that there is one style that won't allow itself to be changed. I have tried the following:

- changing the style of the table (table.range.style) to TableText
- selecting the table (table.select) and changing the selection's style to TableText (selection.style="tabletext")
- looping through the table and changing each row's style to TableText (count the # of rows, then doing a loop from 1=2 to count, rows(i).range.style=Tabletext)
- selecting each row and changing the style of the row itself (row(i).range.style=tabletext)

Each one of them works beautifully (i.e., the styles change as they should), except for this one specific style. That one stays the same, no matter how I attack it. The "problem style" is applied only to a few characters within the cell, not the whole row/cell.

If I select the row manually and apply the style, the prolem-style changes as it should. But not when I do it within a macro.

Any ideas? Thanks!

fumei
08-28-2007, 12:41 PM
Sigh. Let me read your mind.

except for this one specific style

Ummm, care to tell us "specicially" what it is?

Two suggestions though.

1. Try ClearFormatting first.
2. Check if this unnamed, un-described, style is a character style. I suspect so, as you mention it affects characters.

If that is the case, then ClearFormatting should fix this.

crowfan
08-28-2007, 02:08 PM
ClearFormatting worked. Thanks.

I didn't list the style name because it's a long, ugly, hard to type custom name. I didn't know having the specific name mattered so much. I'm not terribly experienced with this. For the record, it's "C101_Text_Step_Number + Not Bold" and it is a Character Style.

fumei
08-28-2007, 02:35 PM
Ah. You are correct really...it does not matter.

stevem00
01-17-2009, 02:05 PM
Oh man, the macro crowfan described is exactly what I'm looking for.

Anyone have something like it?

crowfan
01-17-2009, 03:16 PM
I think I have that macro at work somewhere, though it's been ages since I used it. If I can find it, I'll post it here.

trombonegirl
02-21-2009, 06:34 PM
Also, anytime you see a plus sign after a style that means that there was manual formatting applied on top of the style (in this case, bold). Clear formatting takes care of that as well, since bolding is formatting (and the rest is styles) -- hence the name of the Task Pane "Styles AND Formatting".