ExtendScript of the Week: Applying a particular table style to all the tables in a document
Continuing with the “ExtendScript of the Week” series , this week we are providing a script to apply a particular table style to all the tables in a document. Before applying the format it removes all the cell formatting overrides if present in any of the tables. This Script demonstrates the power and ease with which tables can be manipulated in FrameMaker via ExtendScript.
About the Script:
- On execution ,this script prompts the user to enter any existing table style in a document.
- It then iterates over all the tables and removes any cell formatting overrides if present in any of the table.This is done only for those tables present on Body page
- It then applies the table style entered by the user to all the tables in the document. Again this is done only for those tables present on Body Page.
- Finally it alerts the user about the number of tables on which the format got applied.
Running the Script against a sample document:
- Open the attached document “test2.fm” in FM and make sure that it has focus.
- Note that there are 3 tables in the document. Tag “Format A” has been applied on the first and third while
“Format B” has been applied on the second one
- For running the script , click File->Script->Run and then browse for the script. When prompted for table tag, enter <tagc>.
- After running the script , note that in the test document, “tagc” has been applied on all the tables.
The difference can be seen in the outer border ruling of all the tables which will now be thick.
For Sample file and Script, Click on the link below and then Unzip the downloaded file to get the test file and script.