Copy link to clipboard
Copied
Hi all,
I am looking for examples how to apply own Body Text Paragraph Style to [No Paragraph] Style. The Body Text is a part of Group EN:
Normally I would use Find/Change dialog but I believe there is a better way with scripting?
Copy link to clipboard
Copied
Hi,
var myDoc = app.activeDocument,
myParaStylesGroup = myDoc.paragraphStyleGroups.item('EN'),
myParaStyle = myParaStylesGroup.paragraphStyles.item('Body Text');
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.appliedParagraphStyle = myDoc.paragraphStyles[0];
app.changeGrepPreferences.appliedParagraphStyle = myParaStyle;
myDoc.changeGrep();
app.findGrepPreferences = app.changeGrepPreferences = null;
(^/)
Copy link to clipboard
Copied
Works!
I was tinkering :
try{
app.activeDocument.textFrames[0].insertionPoints[0].select();
var pStyleGroup = app.activeDocument.paragraphStyleGroups.itemByName('EN');
var titleStyle = pStyleGroup.paragraphStyles.itemByName('Body Text')
app.activeDocument.paragraphs[0].applyParagraphStyle (app.activeDocument.paragraphStyles.item ("Body Text", true));
}catch(e){};
How about 'try': if for instance my Paragraph style will be different and I don't wanna see the error thrown by JavaScript? (will manually apply the style with that different name afterwards)
Copy link to clipboard
Copied
Pete Stan wrote:
… Normally I would use Find/Change dialog but I believe there is a better way with scripting?
Hi Pete,
why do you believe that scripting is a better way?
Would you like to add something to the process by scripting what Find/Change cannot do?
Regards,
Uwe
Copy link to clipboard
Copied
Yes, To make my life easier!
I have already a script that places a Word Document, auto-flows on A4, runs Jongware's PrepText, asks me to load the styles and now I can skip the step I was performing manually