Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    199
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Shading Word Tables (Word2K)

    Hi,

    We have a document which is a table of Contacts and phone numbers about 6 pages long which is updated each month. We want to make this document easier to read and use.

    When we do an update we would like to have a macro which would select the table assuming the cursor is within the table and set the shading so that every alternate row after the single row heading was shaded. Each month there are additions and deletions so the shading would need to be removed and then re-built, or updated so that the new document was correctly shaded regardless of the old.

    Any macro experts like to provide a good solution.

    Thanks in Advance,

    Peter Moran
    Two heads are always better than one!!

  2. #2
    5 Star Lounger
    Join Date
    Dec 2000
    Location
    Tallahassee, Florida, USA
    Posts
    901
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Shading Word Tables (Word2K)

    Hi, Peter. No real need for a macro. If you use Table / AutoFormat and select List 1 (or other preferred format from the list), once you've rebuilt your table, put your cursor in and use the shortcut key combo of Ctrl+Alt+u.

    If you really, really want to automate, then the line of code is:
    <pre> Selection.Tables(1).UpdateAutoFormat</pre>


    HTH
    Karen

  3. #3
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    199
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Re: Shading Word Tables (Word2K)

    Hi Karen,

    Even simpler than I hoped! Great!

    Thanks

    Peter Moran
    Two heads are always better than one!!

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Shading Word Tables (Word2K)

    Oops, I never use AutoFormat, so I wrote a macro. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    <pre>Option Explicit
    Sub TableShader()
    ' Jefferson Scher 9 Jan 2003
    ' Sniff whether we're in the right place
    If Not Selection.Information(wdWithInTable) Then
    MsgBox "Please click in the table and try again."
    Exit Sub
    End If
    ' Set up colors... listed in the object browser (F2)
    Dim lngOddRowBGColor As Long, lngEvenRowBGColor As Long
    lngOddRowBGColor = wdColorGray20
    lngEvenRowBGColor = wdColorGray10
    ' Loop through the rows and reset the shading
    Dim lngCounter As Long
    With Selection.Tables(1)
    For lngCounter = 1 To .Rows.Count
    ' These properties were discovered by recording a macro...
    With .Rows(lngCounter).Cells.Shading
    .Texture = wdTextureNone
    .ForegroundPatternColor = wdColorAutomatic
    ' Alternate colors for odd and even rows by
    ' checking remainder when dividing loop counter by 2
    .BackgroundPatternColor = IIf(lngCounter Mod 2 <> 0, _
    lngOddRowBGColor, lngEvenRowBGColor)
    End With
    Next
    End With
    End Sub</pre>

    You can fall back on this if AutoFormat doesn't fulfill your needs.

  5. #5
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    199
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Re: Shading Word Tables (Word2K)

    Hi Jefferson,

    Thanks a million, but the Auotformat look too easy to overlook.

    Regards,

    Peter Moran
    Two heads are always better than one!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •