Results 1 to 6 of 6
  1. #1
    5 Star Lounger
    Join Date
    Jan 2002
    Location
    Midlothian, Virginia, USA
    Posts
    875
    Thanks
    0
    Thanked 2 Times in 1 Post

    Table Borders after Merge (Word 97)

    I'm doing a mail merge which contains 6-8 little 1-line tables to help format the resulting text. Each table is contained in an IF field that makes the presence of the line and the table that contains it depend on a condition that is contained in a MERGE field. I am getting correct results in every sense except that I don't want the table borders to be visible in the merged document. Each table in the mail merge "main document" has its borders turned off but the resulting tables in the merge result document have borders turned on.

    Is there any way to make the table borders remain off in the merged result? I've tried to use * MERGEFORMAT in what seems like the correct places and that hasn't helped.

    If there is no other way, maybe I have to run some VBA code that steps through the variable number of tables and turns off the borders in all the tables. If that is the only alternative, can someone outline the code steps that would do this?

    Thanks,
    Bill

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Table Borders after Merge (Word 97)

    Hi Bill,

    Strangely enough, I get borderless tables in a quick test. I used an IF field with code like this:

    { IF { MERGEFIELD ToBeShown } = 1 "<table border=1><td> This </td><td> That </td></table>" "" }

    The border is shown here for demonstration purposes only; both in the main document and in the merged document there were no borders.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2002
    Location
    Midlothian, Virginia, USA
    Posts
    875
    Thanks
    0
    Thanked 2 Times in 1 Post

    Re: Table Borders after Merge (Word 97)

    Hans, thanks for trying that test. Your results are surprising! Your field arrangement looks just like mine I believe. Except, I have a set of about 6 of those entries all enclosed in an outer level IF. I have three seperate sets of these outer IFs with different contents because I have three different formats to use under different conditions. Maybe the two levels of IFs causes the difference between my results and yours. I'll review mine again carefully to make sure I really am using the same format you have shown.

    My mail merge is being run entirely automatically by VBA code in Access so my code could be designed to step through the tables and change all their borders in the resulting document if I knew how to do it. Unfortunately, I know very little about writing code for Word. All my experience is in Access. If you or someone else knows how to step through all the tables and change the table borders in code that would be a very big help since my mail merge is failing to carry the border conditions from the main document into the result document.

    Thanks for replying so quickly.

    Bill

  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

    Remove borders from all tables (Word 97)

    So you want to remove borders from all your tables in one quick go? I used the macro recorder to capture the procedure Format|Borders|None|Okay, and it generated the guts of this procedure. I then added some logic to loop through all the tables:
    <pre>Sub UnBorderMyTables()
    Dim tbl As Table
    For Each tbl In ActiveDocument.Tables
    With tbl
    .Borders(wdBorderLeft).LineStyle = wdLineStyleNone
    .Borders(wdBorderRight).LineStyle = wdLineStyleNone
    .Borders(wdBorderTop).LineStyle = wdLineStyleNone
    .Borders(wdBorderBottom).LineStyle = wdLineStyleNone
    .Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
    .Borders(wdBorderVertical).LineStyle = wdLineStyleNone
    .Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
    .Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
    End With
    Next
    End Sub</pre>

    Functional, for sure, but further exploration of the object model yields a faster technique:
    <pre>Sub UnBorderMyTables2()
    Dim tbl As Table
    For Each tbl In ActiveDocument.Tables
    tbl.Borders.Enable = wdLineStyleNone
    Next
    End Sub</pre>

    This was tested in Word 2000. I sure hope it works in Word 97!!

  5. #5
    5 Star Lounger
    Join Date
    Jan 2002
    Location
    Midlothian, Virginia, USA
    Posts
    875
    Thanks
    0
    Thanked 2 Times in 1 Post

    Re: Remove borders from all tables (Word 97)

    Thanks Jefferson. That is just what I was looking for. As it has turned out, I haven't needed to use your solution. I found that I had not actually removed the borders from the tables in the mail merge main document! Once I really had those borders removed, they stayed off in the mail merge result as I had originally hoped would happen.

    I'm going to save your table processing code for future reference.

    Thanks,
    Bill

  6. #6
    5 Star Lounger
    Join Date
    Jan 2002
    Location
    Midlothian, Virginia, USA
    Posts
    875
    Thanks
    0
    Thanked 2 Times in 1 Post

    Re: Table Borders after Merge (Word 97)

    Hans, I've discovered that I actually didn't remove the borders from the tables in the mail merge main document! I had misinterpreted what I was seeing on the Word screen. After really turning off the table borders, they remain off in the mail merge result document as you reported. Finally, I'm getting the right result!

    Thanks for reporting your test!

    Bill

Posting Permissions

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