Consulting

Results 1 to 2 of 2

Thread: Tables - First Row to Always be Grey

  1. #1
    VBAX Regular
    Joined
    Nov 2020
    Posts
    15
    Location

    Tables - First Row to Always be Grey

    Hi,

    When I set a table to Style1, the first row is set as a Header and is grey. If I delete that first row, the second row becomes the first row, and then turns grey automatically, obviously. But, I'm wondering if this can be duplicated in VBA, or if I just have to keep running the macro whenever I want to fix the header to grey. (There are other differences in the first row like bold font, different borders, etc, but I'm simplifying it here).

    I know that using VBA to set tables to Style1 will work. But, that is no fun.So, is there any way to add code so that no matter which line in the table ends up at as the first row, it will always be grey?
    This is what I already use:

    Tbl.Rows.First.HeadingFormat = True
    Tbl.Rows.First.Select
    Selection.Shading.ForegroundPatternColor = wdColorGray05



    Anyone have a magical way? I do not want to always be going in to my styles and changing Style1 when I want to change something in the header row or any other part of the table, otherwise, I'd just use Style1. I know I should just stick with a style and be happy, but VBA tables are so much fun to change.

    Hopefully this makes sense.

    Thanks!
    -Ashley

  2. #2
    Word comes with over 100 pre-configured table styles, all of which may be edited, or you can add your own table style to that number. It doesn't appear to make any sense to just use one style for all tables.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Tags for this Thread

Posting Permissions

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