applescript align column in word table

Discussion in 'Mac Programming' started by Freez, Jan 24, 2014.

  1. Freez, Jan 24, 2014
    Last edited: Jan 24, 2014

    Freez macrumors newbie

    Joined:
    Feb 9, 2011
    #1
    I am stuck on how to right align a column of a Microsoft Word table using applescript.

    Any advice would be appreciated.

    This doesn't work.

    Code:
    tell application "Microsoft Word"
    	
    	set txt to selection's text object
    	set default table separator to tab
    	set theResult to convert to table txt
    	set myTable to table 1 of the active document
    	auto fit behavior myTable behavior auto fit content
    	set paragraph alignment of {myTable, column 3} to align paragraph right
    end tell
    
    osx 10.9.1, Microsoft Word for mac 2011 14.3.9, applescript 2.3
     
  2. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    You can do something like this :

    Code:
    tell application "Microsoft Word"
    	set myTable to table 1 of the active document
    	repeat with i from 1 to count rows of myTable
    		set alignment of paragraph format of text object of (get cell from table myTable row i column 3) to align paragraph right
    	end repeat
    end tell
    
     
  3. Freez thread starter macrumors newbie

    Joined:
    Feb 9, 2011
    #3
    Perfect.

    Kryten2 thank you for the help. Works great!!
     

Share This Page