Copy link to clipboard
Copied
I have a Word doc with some simple html tags, ie. <CT> for the chapter title. Is there a way for me to globally change the paragraph following the tag to a existing paragraph style?
Brian is right. Find/Change will do the job. You can also use a script to do this.
Does the paragraph styles names the same of the tag content?
If yes, you can use this:
//DESCRIPTION: Apply pStyle based on tag
//=============================================================
// Script by Luis Felipe Corullón
// Contato: lf@corullon.com.br
// Site: http://scripts.corullon.com.br
// +55 (51) 9-9685.7565
// Version: 20200715_2128_GMT-3
//============================================================
...
Copy link to clipboard
Copied
Find/Replace should do. Find the tag, replace with the same tag and change the paragraph style to the desired one?
Copy link to clipboard
Copied
Thank you. That would certainly work, but I am looking for a quicker, more global way of approaching this. A year or so ago I had found a script, lost it, and can't seem to google it up, again.
Copy link to clipboard
Copied
Brian is right. Find/Change will do the job. You can also use a script to do this.
Does the paragraph styles names the same of the tag content?
If yes, you can use this:
//DESCRIPTION: Apply pStyle based on tag
//=============================================================
// Script by Luis Felipe Corullón
// Contato: lf@corullon.com.br
// Site: http://scripts.corullon.com.br
// +55 (51) 9-9685.7565
// Version: 20200715_2128_GMT-3
//=============================================================
var myScriptName = "Apply pStyle based on tag";
var myIDversion = app.version.split(".")[0];
if (!app.documents.length || (app.documents.length && !app.documents[0].visible)) {
alert("There is no opened document." , "Script by LFCorullón" , true);
}
else {
if (myIDversion < 6) main();
else app.doScript(main, ScriptLanguage.javascript, undefined, UndoModes.entireScript, myScriptName);
}
function main() {
var doc = app.activeDocument;
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.findWhat = "<.+?>";
var f = doc.findGrep();
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
for (var i=0; i<f.length; i++) {
var c = f[i].contents.replace(/<|>/g , "");
for (var j=0; j<doc.allParagraphStyles.length; j++) {
if (doc.allParagraphStyles[j].name == c) {
f[i].appliedParagraphStyle = doc.allParagraphStyles[j];
}
}
}
}
 
Copy link to clipboard
Copied
I do believe this is the script. Thank you so very much!!!