[Date Prev][Date Next] [Thread Prev][Thread Next]
[Date Index] [Thread Index] [New search]

AppleScript to set table column widths



After setting up a bunch of text insets and conditionals to single-source 
an
installation manual & quick-install sheet, I ran into the hassle with 
tables
coming in with a fixed width. Searching the archives didn't produce a 
solution,
but Rick Quatro pointed out that one could use FrameScript to adjust the
column widths for a table inside a text inset.

Duplicating this feat with AppleScript took less time than I thought it
would. The source code follows; you will certainly want to change the
hardcoded "set column widths" and "set alignment" statements to suit
your needs. Watch for line wrapping!

Improvements are appreciated, of course. One possibility would be to
get the current table column widths and proportionally resize them
to the column width of the current/active document.

Select a text inset that contains only a table before running the script.


tell application "FrameMaker+SGML 6.0" 
        tell active document        -- I know, I know...
 
                set theTabs to (tables)
                set mySel to selection -- We operate on the selected table
 
                -- The only way I know to identify a selected table is
                -- to compare the selection to a list of tables.
                -- Is there a better way?
                repeat with oneTab in theTabs
 
                        set x1 to (location of oneTab)
                        if (mySel = x1) then
                                -- column widths are in points
                                set column widths of oneTab to {32.184, 32.184, 32.184, 32.184, 32.184, 104.832}
                                set alignment of oneTab to align right
                        end if
 
                end repeat
 
        end tell
end tell


AppleScript is my hammer, FrameMaker is my nail. :-)

--
Larry Kollar, Senior Technical Writer, ARRIS
"Content creators are the engine that drives
value in the information life cycle."
    -- Barry Schaeffer, on XML-Doc

** To unsubscribe, send a message to majordomo@omsys.com **
** with "unsubscribe framers" (no quotes) in the body.   **