0 Replies Latest reply: May 5, 2013 2:39 AM by LogicProLetsGo
LogicProLetsGo Level 1 Level 1 (0 points)

Microsoft Word has a flaw (in my opinion) with tables in that it aligns the left and right text with the margins rather than aligning the table columns with the margins. This results in sloppy tables, because the left and right borderlines lie outside the margins.


I would like to fix the word tables by

  • calculating the left cell padding and right cell padding in points and setting them to variables {left_pad,right_pad} respectively
  • move left column by left_pad to the right
  • move right column by right_pad to the left


The script I was working on does not work, but I will post it to show my thought process as I hone in on my solution.


tell application "Microsoft Word"

    --595 points is width of A4 paper



    -- Set page margin in points to variables

    set {l_margin, r_margin, t_margin, b_margin} to {(get left margin of page setup of active document), get (right margin of page setup of active document), get (top margin of page setup of active document), get (bottom margin of page setup of active document)}

    get {l_margin, r_margin, t_margin, b_margin}




    -- Set specific Paragraph margins

    -- NOTE: If you select a table thinking you wish to drag just the left margin to the right, or the right margin to the left, this code does not accomplish this because each cell has its own paragraph formatting. This code will set the margin for every single cell, because each cell has its own margins! (separate from padding).

    set para_sel to paragraph format of selection

    set paragraph format left indent of para_sel to (centimeters to points centimeters 0.5)



    -- Aligning left and right columns of table with the margins

    -- NOTE: There is a command to set left row indent, but not right row indent (very stupid of Microsoft)


end tell

MacBook Air, Mac OS X (10.7.2), Microsoft Office 2011 Mac