Skip to main content
Participant
March 16, 2017
Answered

Applying a same character style to different words inside a text

  • March 16, 2017
  • 4 replies
  • 1446 views

Hello,

I am typesetting a book on Persian food which has many words that should be italicised. However the formatting has been lost after copying/pasting from MS Word into inDesign and I can't think of having to re-do it manually.

I have a separate list of words that should be italicised, so I was thinking of applying a character style through a GREP style or similar. However, I don't know how to apply a GREP style to a list of words. Do GREP styles only work for single words? I hope not because I have more than 100 to format...

Thanks in advance for any advise.


Daniele

This topic has been closed for replies.
Correct answer vinny38

Hi

My first thought would be FindChangeByList script.

text

{findWhat:"your word here"}

{appliedCharacterStyle:"italic"}

{includeHiddenLayers:true, includeMasterPages:true, includeFootnotes:true, wholeWord:true, caseSensitive:false}

This would require some manipulation to stick your words in the above pattern.

However, it wouldn't be so difficult to do it in an Excel file.

See what I mean?

However, there might be easier ways, so I would wait for other users answers before going deeper into this process.

4 replies

Erica Gamet
Inspiring
March 16, 2017

When I import text that has been styled, I choose to strip out the styling (which tends not to be correct or consistent) but preserve local overrides. Then, as was suggested above, do a Find on character styling of italic and Replace it with your italic character style. All of this is assuming the original text is italicized where you need it.

Participating Frequently
March 16, 2017

If you are using CC ( it may also be in earlier versions), you can turn on "All information" under clipboard handling. This will allow you to preserve your word italicizing. From there, you can search for paragraph and character styles using command+f and apply your new character styles, or you can simply format the ones that will be brought in from word.

hope that does it!

Legend
March 16, 2017

If you use Place instead of copy-paste, does that keep your italic formatting?

jane-e
Community Expert
Community Expert
March 16, 2017

File > Place by default keeps your formatting such as italics

Copy > Paste does not

Clipboard Handling Preferences can be changed:

as can Import Options for placing:

vinny38
vinny38Correct answer
Legend
March 16, 2017

Hi

My first thought would be FindChangeByList script.

text

{findWhat:"your word here"}

{appliedCharacterStyle:"italic"}

{includeHiddenLayers:true, includeMasterPages:true, includeFootnotes:true, wholeWord:true, caseSensitive:false}

This would require some manipulation to stick your words in the above pattern.

However, it wouldn't be so difficult to do it in an Excel file.

See what I mean?

However, there might be easier ways, so I would wait for other users answers before going deeper into this process.

Obi-wan Kenobi
Legend
March 16, 2017

Hi,

… When all has already been written … since five years! …

textFile = File(Folder.myDocuments+"/list.txt"); 

if (textFile.open("r") == false) 

   { alert ("yeah ... that file does not exist"); exit(0); }

  

strs = textFile.read (); 

textFile.close(); 

strs = strs.split("\n"); 

app.findGrepPreferences = app.changeGrepPreferences = null; 

app.changeGrepPreferences.appliedCharacterStyle = app.activeDocument.characterStyles.item("yourStyle"); 

while (strs.length > 0) 

app.findGrepPreferences.findWhat = "\\b"+strs.pop()+"\\b"; 

app.activeDocument.changeGrep(); 

}

(^/) 

Obi-wan Kenobi
Legend
March 16, 2017

… with this "French Touch" variant! 

textFile = File(File($.fileName).parent.fullName + "/list.txt"); 

(^/)