Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Changing the name of every style in a document

Return to Member Forum

  • Author
    Posts
    • #56000

      I have an InDesign document with about 30–40 paragraph styles. I have a Word document with the same set of styles but different names. The styles in the InDesign document need to be renamed with the names of the Word styles.

      If I simply import the styles and use delete/replace with, then I lose all the inheritance and any GREP or nested styles. Is there any way of merging the two sets of styles, such that they retain the properties of the original styles but acquire the name of the imported Word styles?

      Thanks!

    • #56001
      David Blatner
      Keymaster

      You may not need to rename the styles. Instead, you could create a “style mapping” that maps from the Word doc names to your ID doc names. You can do that in the Import Options dialog box (when placing). After you do it, save it as a Preset in that dialog box so you can recall it again next time

    • #56002

      Yes, I'd thought of that, but this is to be the new style template: once I've finalised the styles in InDesign I'll export it back to RTF to create the document template for Word files.

      Besides, it's easier for everyone if the styles have the same names in both InDesign and Word.

    • #56003

      OK, rather than try and map the new styles to the old ones automatically (how would ID know which ones to use?), I'm playing with the idea of creating a dialog box for each paragraph style in the document in turn, so I can type in the new name. (Yes, I know I've probably already taken more time than it would take to click on each style manually, but I've never written a script with a dialog in it before so I thought I'd take the opportunity to learn.)

      I've adapted one of the examples in the Applescript tutorial. So far I have:

      tell application “Adobe InDesign CS5”

      tell active document

      set allParaStyles to every paragraph style

      repeat with i from 1 to count of allParaStyles

      set myParaStyle to item i of allParaStyles

      set myOldStyleName to name of myParaStyle

      set myDialog to make dialog

      tell myDialog

      set name to “Rename paragraph style”

      set myDialogColumn to make dialog column

      tell myDialogColumn

      –Create a text entry field.

      set myNewStyleName to make text editbox with properties {edit contents:”myOldStyleName”, min width:180}

      end tell

      end tell

      set myResult to show myDialog

      if myResult is true then

      –Get the settings from the dialog box.

      set name of myParaStyle to edit value of myNewStyleName

      –Remove the dialog box from memory.

      destroy myDialog

      else

      destroy myDialog

      end if

      end repeat

      end tell

      end tell

      But this gives me an error:

      error “Adobe InDesign CS5 got an error: Can’t make class dialog.” number -2710 from dialog to class

      What am I missing?
    • #56302
      Billy Chase
      Member

      Another way to tackle this is to create a paragraph return for each style and style it. Then you can export the InDesign document out to a word file that contains all the styles.

      I think this might be a Deke McClelland trick that I learned a while back. I haven't actually tried it because I haven't been faced with a situation that needed it or if it did need it then the editor already had their system in place.

    • #56422

      inkeye said:

      Another way to tackle this is to create a paragraph return for each style and style it. Then you can export the InDesign document out to a word file that contains all the styles.


      Yes, that's what I plan to do – once all the styles have the correct names!

    • #56434

      I think this might be what you are looking for. This script is written in JavaScript so it should work on either platform.

      Copy and paste the text below into a blank text file and save it with a *.jsx extension.

      You will need to save this file in your Scripts folder (wherever that is located on your hard drive).

      I'm assuming that you have used scripts before and are familiar with where they are located and how to run them.

      If not, just ask, and I will try to guide you through the process more thoroughly.

      RenameStyles();

      function RenameStyles() {

      myDoc = app.documents[0];

      if ( myDoc == null ) { exit }

      else if ( myDoc != null || myDoc != 0 ) {

      myStyle = myDoc.paragraphStyles.item(“INDD_StyleName1”);
      if (myStyle != null) try { { myStyle.name = “Word_StyleName1” } } catch (myError) { exit }


      myStyle = myDoc.paragraphStyles.item(“INDD_StyleName2”);
      if (myStyle != null) try { { myStyle.name = “Word_StyleName2” } } catch (myError) { exit }

      myStyle = myDoc.paragraphStyles.item(“INDD_StyleName3”);
      if (myStyle != null) try { { myStyle.name = “Word_StyleName3” } } catch (myError) { exit }

      }

      }

      Good luck!

      Theresa

    • #56462

      That looks ideal! Thanks! I have several of these to do (all with the same target style names), so this is going to make my life much easier.

Viewing 7 reply threads
  • You must be logged in to reply to this topic.
Forum Ads