none
Word GUI setting table borders does not set expected borders for each cell RRS feed

  • Question

  • When I select a table that has 3 rows and I select the first row to place a "box" border setting.  Upon investigating each cell I am finding that the first row correctly has the bottom border turned on for each cell in the row.   However in the second row below, those cells also have the "top" border setting turned on.   I have code that is repeating the second row to create additional rows of data and I do not want bottom or top borders on those rows as they dynamically generate.   Can anyone explain why Word does this and how to set the table so I get the desired output?

     

       --TR

    Friday, August 19, 2011 11:06 PM

All replies

  • Change your code to use the third row that does not have top or bottom borders.

    Since Row 1 shares its bottom border with Row 2's top border that is why you get a top border on Row 3 when you insert it from a copy of Row 2.  If you are starting with a 2-row table then your code will have to remove the unwanted top border after inserting a copy of row 2. If you are starting from a 3-row table then just copy row 3 instead of copying row 2.  


    Kind Regards, Rich ... http://greatcirclelearning.com
    Saturday, August 20, 2011 10:15 AM
  • Rich,

     

    Thanks for the fast response.  I will try this out and let you know my results.

     

       --TR

    Monday, August 22, 2011 5:51 PM
  • Hi;

    Isn't there a way to set the bottom border of Row 1 to the desired width and the top border of row 2 to no border? You can edit a DOCX file directly to get it so Word should have a way to do it???

    thanks - dave


    The future of B.I. - Raw & Uncut
    Monday, August 22, 2011 5:52 PM
  • Hi TeleRiddler_msdn,

    How about the problem on your side? Do the suggestions help you? If you still need any assistant, just feel free to let us know.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, August 24, 2011 6:38 AM
  • Hi Bruce;

    I work with Ryan and the answer above won't work for us. We can't change our code because this is not a hard-coded case of a specific document, it is that we have to handle all documents. Our users will mark which row(s) to repeat and we have to then take those rows and repeat them.

    Our users see a border around row 1 and none on row 2 and expect row 2 to duplicate with no border. We have to give them a way to set the bottom border on row 1 and clear it on row 2. How can we do that?

    thanks - dave


    The future of B.I. - Raw & Uncut
    Wednesday, August 24, 2011 3:55 PM
  • Hi Dave,

    Why do you want to set the bottom border on row 1 and clear it on row2? I am not very clear about this.

    I think you can set the top border of row 2 to be none. Do you want to programmatically setting it?

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Thursday, August 25, 2011 6:45 AM
  • Hi Bruce;

    Try it - set a border to go around row 1 and then look at the border settings. Word has the bottom of row 1 set to none and the top of row 2 set to a border. If you then clear the top of row 2 and set row 1 - it does it again.

    We're trying to do this with word. (Programatically this can easily be done.)

    ??? - thanks - dave


    The future of B.I. - Raw & Uncut
    Thursday, August 25, 2011 2:56 PM
  • Hi Dave,

    I'm confused about this; can you explain a bit more of what you mean. Rows 1 and 2 have a shared horizontal border. Nothing I do in either the Word UI or VBA makes them different. (Word 2010 SP1 64-bit if it matters). And how does a user see a border on row 1 and none on row 2?

     


    Enjoy,
    Tony
    www.WordArticles.com
    Thursday, August 25, 2011 5:32 PM
  • Hi Tony;

    Please take a look at http://www.windwardreports.com/temp/BorderIssue.docx - we cannot find a way in Word to give the first row a bottom border and the second row no top border.

    thanks - dave


    The future of B.I. - Raw & Uncut
    Thursday, August 25, 2011 11:23 PM
  • The second row in your table has an explicit top border in the XML.
     
    There is - AFAIK - no way in Word to give the rows different settings for the border they visually share. If you have set different borders in the XML, Word appears to report them wrongly via the OM (and I would say that was a bug) but, if copied and pasted, it does appear to do things correctly.
     
    What is your real-world scenario with this?
     

    Enjoy,
    Tony
    www.WordArticles.com
    Friday, August 26, 2011 8:30 AM
  • Hi Tony;

    Our situation is our users design reports in Word and we use that Word document as a template to create a report. They can place forEach start/finish markers anywhere so we fundamentally have to handle any use.

    The particular use where this came up is a 3 row table where the user marked a forEach loop to start at the ebginning of the 2nd row and end at the start of the 3rd row. So the middle row is duplicated once for each row of data.

    They want the top row to have a border and the middle rows to not have a border. Since we take that middle row and duplicate it, we need for that middle row to have no border. And for the top row to have a bottom border.

    Because we're free-form, this is not something where we can add a button for "the border on this row is actually on that row" because everyone's use is different.

    So how can we tell Word to place a bottom border on row 1 and none on row 2? And from the Word UI, not the COM API because it is our customers doing this and they aren't writing code.

    ??? - thanks - dave


    The future of B.I. - Raw & Uncut
    Friday, August 26, 2011 2:47 PM
  • Well, I was going to say you couldn't do this through the UI but thought I'd play a little first :-)
     
    Through the UI ... if you create a table and put a border round the top row, this puts a top border on the second row; if you then delete the second row, what was the third row becomes the second, but now ... although you still see the border round the top row and visibly on the second row, if you insert a row, or copy and paste the second row the top row border is not copied.
     
    You will need to experiment a little; it appears as though VBA reports the border at the top of the second row but doesn't 'use' it. It seems, from my quick tests, that you may be able to add a row before setting your borders and then delete it to get the effect you want.
     

    Enjoy,
    Tony
    www.WordArticles.com
    Saturday, August 27, 2011 11:39 AM