Consulting

Results 1 to 4 of 4

Thread: Word Table styles - buggy behaviour...

  1. #1
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location

    Word Table styles - buggy behaviour...

    Hi all,

    I have a bit of "unexpected behaviour" in Word (2003) I'm hoping to resolve with someone's help.
    I have a template that uses a few table styles. All these Table styles have a 1pt border on the top and bottom of the whole table and one of them uses stripes (alternate 25% grey shading on the rows).
    My first problem was that when applying a style from the task pane, the default behaviour was to have 'Apply special formats to:' switched on for first/last row/column. There doesn't seem to be a way of saving these preferences with the style. Is there a way of doing that???

    I got round that by adding my styles to my custom toolbar and running this code: [VBA]With Selection.Tables(1)
    'the style names match the button captions so it's one routine for all
    .Style = Application.CommandBars.ActionControl.Caption
    .ApplyStyleHeadingRows = True
    .ApplyStyleLastRow = False
    .ApplyStyleFirstColumn = False
    .ApplyStyleLastColumn = False
    End With[/VBA]
    Problem solved? No, I run this code from my tool bar and the border on the bottom of the table doesn't always appear. I can only make it appear by running the code and then pressing Ctrl+Y!!??? If run the code twice it still makes no difference.
    Stumped
    K :-)

  2. #2
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Hi Killian,

    The consensus, as far as I can tell, is that Table Styles are a nice idea, but that they are not yet ready for serious use. I know Gerry (fumei) loves them but he is about the only person I've found with much good to say about them.

    There is an element of conflict, and more than a little confusion, in the way Table Styles sit with the 'old' AutoFormats, and that seems to come into play with the various ApplyStyle properties. Contrary to the Help files, and the Macro Recorder, they really don't work.

    I don't think they are really meant to be used with Styles. When you think about it, selecting which elements of a style you want to apply isn't what you do with paragraph styles, so why should it work with table styles? Set the style up the way you want and apply it is about the best answer I can come up with.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  3. #3
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    No of course not. When you play with PARTS of a style, then it is not that style any more.

    Help on this matter lies. Their example does not work.

    I too have tried individual .ApplyStyle_whatever = whatever (True or False), and it does not work as advertised. So, sure, in one sense Tony, you are correct. They are still a bit buggy. However, I do not alter Styles on the fly. I design styles as solid objects.

  4. #4
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location

    UPDATE: A workaround, rather than a solution

    It would appear there is, in fact, no facility to save the ApplyStyleLastRow setting with your Table style, which is clearly an oversight.
    After extensive testing, the only way to get the bottom border to apply is[VBA]SendKeys "^Y"[/VBA] (curiously Application.Repeat doesn't do it) which I'm not prepared to use in distrubuted code.
    I decided to go with the flow on this and employ a workaround since it's obvious that it's a Word bug...
    Since I only have two types of bottom border in use I'm jsut going to re-apply it and move on.[VBA]With Selection.Tables(1)
    .Style = Application.CommandBars.ActionControl.Caption
    .ApplyStyleHeadingRows = True
    .ApplyStyleLastRow = False
    .ApplyStyleFirstColumn = False
    .ApplyStyleLastColumn = False

    With .Borders(wdBorderBottom)
    .Visible = True
    .LineStyle = wdLineStyleSingle
    .LineWidth = wdLineWidth100pt
    If Right(Application.CommandBars.ActionControl.Caption, 4) = "Grey" Then
    .Color = wdColorGray25
    Else
    .Color = wdColorDarkRed
    End If
    End With

    End With
    [/VBA] It's a bit disappointing because I had high hopes for table styles. For a user to be able to apply a pre-defined format (that can be saved with the template rather than doing it all with code) to a table without effecting the paragraph styles they've chosen would clearly be a useful addition to Word if it worked reliably...
    Thanks for the comments guys
    K :-)

Posting Permissions

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