1

I have been looking for the answer to this for quite some time, but to no avail, so I hope someone here will be able to help me.

I have recently exported a document from FineReader 12 to word. The document is basically a 130-page-long table. The table has a regular shape: 5 columns, no merged cells.

However, when I merge individual tables (FineReader splits them by page) into one by deleting the lines between them, the table gets an irregular shape on each joint, like this:

this.

Given the sheer number of tables I have, is there a way to reset their shape altogether? So far it seems I have to manually adjust each table's columns to fit the other ones.

I have tried resetting the table and column width, text wrapping etc.; I also selected the entire table and checked, then unchecked the "table header" tick for all.

Converting table to text and back doesn't work, because some cells have paragraph breaks, and that's to be dealt with later.

0

Okay, I was given an answer by Paul Edstein aka macropod at MS Office Forums which I slightly modified and it works like charm now. I paste the solution here as it might save dozens of hours of work for anybody working with OCR and whatnot.

The idea is to make a macro that reformats layout of each table (and each cell if needed), like that:

Sub FixTables()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim Tbl As Table, i As Long
With ActiveDocument
    For Each Tbl In .Tables
        With Tbl
            With .Rows
                .LeftIndent = 0
                .WrapAroundText = False
                .Alignment = wdAlignRowCenter
            End With
            .TopPadding = 0
            .LeftPadding = 0
            .RightPadding = 0
            .BottomPadding = 0
            .AllowAutoFit = False
            .PreferredWidthType = wdPreferredWidthAuto
            If .Uniform Then
                .Columns(1).Width = CentimetersToPoints(1#)
                .Columns(2).Width = CentimetersToPoints(3.75)
                .Columns(3).Width = CentimetersToPoints(3.75)
                .Columns(4).Width = CentimetersToPoints(3.75)
                .Columns(5).Width = CentimetersToPoints(3.75)
            Else
                For i = 1 To .Range.Cells.Count
                    Select Case (i - 1 Mod 5) + 1
                        Case 1: .Range.Cells(i).Width = CentimetersToPoints(1#)
                        Case Else: .Range.Cells(i).Width = CentimetersToPoints(3.75)
                    End Select
                Next
            End If
    End With
    While .Tables.Count > 1
        .Tables(1).Range.Characters.Last.Next.Delete
    Wend
Next
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub

The only downside is that while it executes in just a couple of seconds with only 3 tables, it took about 15 minutes to perform the changes on a set of 50 tables. The tweaks to that include temporarily turning off the screen refresh in word and suppressing all alerts (it would otherwise ask to save the changes each time Word ran out of RAM).

Please note that this solution is adapted for 5 colums only, so tweak it accordingly!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.