Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
Ed Sheehan Ed Sheehan is offline
external usenet poster
 
Posts: 14
Default Apply portions of Auto Format?

I have a table consisting of 150 pages of data with subtotal rows in a
reverse color band. I would like to apply an alternating
gray-band/white-band to every three rows for easy sighting across the page.
Am I stuck with selecting three rows, applying the gray fill, selecting
three more rows (skipping three for white), applying the gray fill, and
repeating 75 times?

Or is there a way to apply these bands more efficiently? If a macro is the
only way, it needs to skip any rows which have color already applied. These
are the subtotal rows.

It doesn't need to stay a table if that helps.

Thanks,

Ed


  #2   Report Post  
Posted to microsoft.public.word.tables
Lene Fredborg Lene Fredborg is offline
external usenet poster
 
Posts: 1,291
Default Apply portions of Auto Format?

The macro below should do what you describe. The selection must be somewhere
in the table when you start the macro.

Note that you need to change the color defined as wdColorLightOrange in the
macro - must be the color you want to keep (your reverse color). To find out
which color that is in VBA, you can record a macro while setting the color -
then locate the BackgroundPatternColor in the macro.

If you add or remove rows in the table, you can simply run the macro again
to reapply colors in 3-row bands.


Sub ChangeTableColor()

Dim oTable As Table
Dim n As Long
Dim i As Long
Dim oRange As Range
Dim oColor As WdColor

Set oTable = Selection.Tables(1)

For n = 1 To oTable.Rows.Count Step 3
'Keep orange shading, else
'Add gray every second time, else remove shading
If n Mod 2 = 0 Then
oColor = wdColorGray125
Else
oColor = wdColorAutomatic
End If

'To keep orange, needed to check rows individually
For i = 0 To 2
If n + i oTable.Rows.Count Then Exit For
Set oRange = oTable.Rows(n + i).Range
'Change to 3 rows
With oRange
'Next line: Change wdColorLightOrange to the color or you
subtotals
If .Cells.Shading.BackgroundPatternColor
wdColorLightOrange Then
.Cells.Shading.BackgroundPatternColor = oColor
End If
End With
Next i
Next n

Set oTable = Nothing
Set oRange = Nothing
MsgBox "Finished applying table color."
End Sub

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"Ed Sheehan" wrote:

I have a table consisting of 150 pages of data with subtotal rows in a
reverse color band. I would like to apply an alternating
gray-band/white-band to every three rows for easy sighting across the page.
Am I stuck with selecting three rows, applying the gray fill, selecting
three more rows (skipping three for white), applying the gray fill, and
repeating 75 times?

Or is there a way to apply these bands more efficiently? If a macro is the
only way, it needs to skip any rows which have color already applied. These
are the subtotal rows.

It doesn't need to stay a table if that helps.

Thanks,

Ed



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make Auto Correct feature apply only to a particular template ? cosmicwonder Microsoft Word Help 1 January 31st 07 03:33 AM
How to make Auto Correct feature apply only to a particular templa bantu Microsoft Word Help 5 January 30th 07 11:47 PM
Why does Word apply format all text rather than selected? ehanley12 Page Layout 1 January 20th 06 03:07 PM
how do i automatically format specific text e.g apply a custom col docmarkh Microsoft Word Help 2 April 3rd 05 08:35 AM
Can I apply auto-formatting to text in the same manner as Auto Cor DBishop Microsoft Word Help 2 February 8th 05 10:27 PM


All times are GMT +1. The time now is 10:41 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"