• Table Borders after Merge (Word 97)

    Author
    Topic
    #380394

    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

    Viewing 0 reply threads
    Author
    Replies
    • #636891

      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 “

      This That

      ” “” }

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

      • #636906

        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

        • #636950

          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:

          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

          Functional, for sure, but further exploration of the object model yields a faster technique:

          Sub UnBorderMyTables2()
          Dim tbl As Table
          For Each tbl In ActiveDocument.Tables
              tbl.Borders.Enable = wdLineStyleNone
          Next
          End Sub

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

          • #637047

            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

      • #637052

        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

    Viewing 0 reply threads
    Reply To: Table Borders after Merge (Word 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: