Manuel,
The second loop wasn't so cool I thought! …
This code is easier to read:
var myDoc = app.activeDocument, myCodes = ["STR 94583", "TRe87 090", "MR 840EOA"], C = myCodes.length, c; app.findTextPreferences = null; for ( c = 0; c < C; c++) { app.findTextPreferences.findWhat = myCodes[c]; myFound = myDoc.findText(); var F = myFound.length, f; for ( f = 0; f < F; f++) { if (myFound[f].appliedParagraphStyle.fontStyle == 'Roman') myFound[f].appliedCharacterStyle = 'Italic'; else if (myFound[f].appliedParagraphStyle.fontStyle == 'Italic') myFound[f].appliedCharacterStyle = 'Roman'; else if (myFound[f].appliedParagraphStyle.fontStyle == 'Bold') myFound[f].appliedCharacterStyle = 'Bold Italic'; else if (myFound[f].appliedParagraphStyle.fontStyle == 'Bold Italic') myFound[f].appliedCharacterStyle = 'Bold'; } } app.findTextPreferences = null;
The code checks the font style used by the para style applied to the para and applies the "contrary" char style as:
Roman => Italic,
Italic => Roman,
Bold => Bold Italic,
Bold Italic => Bold.
Best,
Michel