ExtendScript of the Week: “Change Styles – (Para/Char/Table)”

Wednesday, October 5 2011 @ 4:28 PM, By bharatp

This week in “Extend Script of the Week” initiative we will showcase an extend script which will Find/Change paragraph tags,character tags and table formats on the body page of the document . This script demonstrates one of the several work flows where Extend Script can be used to do tasks in an intuitive and easy way. The script works on Book as well as FM/MIF files.

Information about the script :

  • On running the script an UI appears.
  • Change Style UI

  • This UI contains three radio buttons namely ‘Para Style’,’Char Style’ and ‘Table Style’ and two buttons ‘Change’ and ‘Cancel’.
  • You can choose the style to be changed by clicking on the appropriate radio button and the FIND and CHANGE dropdowns are populated by the styles existing in the active document or if run on a book the styles are taken from the first non generated file in the book.
  • Eg : If you run the script on the attached Sample_Book.book/Doc1.fm then choose ‘Para Style’ radio button.
  • Now choose ‘NewParaFormat-Blue’ in the FIND dropdown .
  • Choose ‘NewParaFormat-Red’ in the CHANGE dropdown.
  • Choose Styles in UI

  • Click on Change button.
  • Now the script will iterate through all paragraphs of all components of the book and wherever the paragraph format is  ‘NewParaFormat-Blue’ ,it is changed to ‘NewParaFormat-Red’.
  • Output File

  • Similarly you can change character formats and table formats in a book or document.
  • After changing the style ,an alert will appear informing the user about the number of changes in the operation.
  • No of Changes :

Steps to Install

  • Download the zip file from ChangeStyles
  • Unzip the files and copy “ChangeStyleMenu.jsx” and “ChangeStyle” folder in startup folder located at “C:\Program Files\Adobe\AdobeFrameMaker10\startup”

How to use the Script?

  • Launch FrameMaker
  • Open a Book File or FM/MIF File
  • Run Change Styles from “File -> Utilities -> Change Styles…
  • This will run the script and ask you for inputs to change the style.
  • Choose the style to be changed in ‘Find’  dropdown.
  • Choose the style to be applied in ‘Change’ dropdown.
  • Click on Change button.
  • If  the script is run on an open FM/MIF file the styles would be changed without saving the document.
  • If the script is run on a Book , all the FM/MIF components which are closed are opened invisibly, the styles are changed and then the files are closed after saving.

I hope this will prove useful to many folks and you can add extra functionality as per your requirements to these scripts to make it even more powerful

Regards,
Bharat Prakash

(Resources: ChangeStyles )

  • http://cap-studio.de/ Michael Müller-Hillebrand

    Bharat,

    The sample files in the download are apparently saved from FrameMaker 11.

    - Michael

    • bharatp

      Hi Michael,

      I have updated the samples files to FM10 version. I have also fixed the bug regarding not being able to type lowercase u letter.
      Kindly download the files now(Same link) and try running them.

      Thanks,
      Bharat Prakash

  • Pingback: ExtendScript der Woche: »Change Styles (Para/Char/Table)« – FrameMaker-Automation mit FrameScript & ExtendScript

  • Heather Ayer

    Thanks for the example. It works beautifully.

    Are there any tips on how to add a paragraph tag first? I have several tables in the doc that were copied in and have been assigned the standard “Table” format. So, in order to change the format, I would first have to add this format to the catalog. Any tips would be greatly appreciated. I’m trying to make the most of this new tool, but there’s not much reference material out there.

    Thanks!

    • Bharat Prakash

      Hi Heather,

      Thanks for the feedback. Right now the script works on the tags already added to the catalog so if you are copying content from other files , the tags have to be added manually.

      Better method would be Importing formats between documents through File>Import>Formats…

      Hope this helps. Kindly let me know if you have any more questions.

      Thanks,
      Bharat Prakash(bharatp@adobe.com)
      FrameMaker Engineering

  • Anh Gauthier

    I’m having trouble changing paragraph tags. It works in the sample fine. But when I use it on my files, it reports that 0 changes have been made when I select valid parameters. Also, in one instance where it does work, it only changes one particular section of an FM file. Any suggestions on what I should try?

    • Bharat Prakash

      Hi Anh,

      Thanks for using the script. Kindly send me some sample files so that i can isolate the issue.

      Thanks,
      Bharat Prakash
      FrameMaker Engineering

  • Bharat Prakash

    Hi Anh,

    I have fixed the issue and mailed you the updated scripts. Kindly let me know if there are any more issues.

    Thanks,
    Bharat Prakash(bharatp@adobe.com)
    FrameMaker Engineering

  • Steve Olsen

    WOW!
    I have multiple documents which need to have character style changes. Thi ssaved me Hours, and hours, and hours.

    Thank you very much!

  • craigede

    I tried this script on a document with two paragraphs called Bulleted and BulletedOutdent. At first the script only changed some of the instances (ignoring others). Finally, it saw none of the Bulleted paragraphs and changed none of them. Bug?

    Also, it would be nice if the menu of paragraph formats were sorted into alphabetical order rather than appearing in some random order.

    I’d be happy to send you the file if you want to look at these problems.

    Thanks you.

    Craig Ede

  • Craig Ede

    At this point I’ve had the opportunity to try this script in a couple of “real world” situations, and I have to say, it is very hit and miss. Something is very wrong with this script since it actually changes only a fraction of the total occurances of a paragraph tag to the new tag and ignores other occurances. I expect the problem is in how it is stepping through the paragraphs and deciding if it is a valid paragraph to change to the new format. Could the writer of the script address this complaint. I’m sure the fix would be instructive to all of us who are interested in Extendscript scripting in FrameMaker.
    Thanks.

  • Categories

  • Archives

  • Authors

  • Useful Links

  • Recent Comments

    • Lois Patterson: I’m always happy to see math support, although I’m not currently using FrameMaker. I have...
    • Olga: I know it’s a really old post but I was unable to find any information online. I need to number the...
    • click: yes. http://wwwimages.adobe.com/www .adobe.com/content/dam/Adobe/e n/volume-licensing/pdfs/avl...
    • tiggyboo: I know the specs say IE 9 or greater is required – but was Server 12 developed specifically for IE or...
    • Ronny: Thank you, thank you!!!