Copy link to clipboard
Copied
Hi all
Hopefully this is simple!…
I have document with a tonne of Heading 3 styles and I need to ensure that the first following paragraph - and only that first paragraph - gets converted to a separately created untabbed body paragraph style.
How do I issue a search and replace command to achieve that?
NB: there are over 700 of these Heading 3 + first following paragraph instances.
Many thanks in advance for any guidance 🙂
VBW
M
A very short way! …
var myParas = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements(),
P = myParas.length, p,
myPStylesList = ["Blue", "Red"]; // Names of the 2 Para Styles to be played!
for ( p = 0; p < P; p++ ) if ( myParas
.appliedParagraphStyle.name == myPStylesList[0] ) myParas[p+1].appliedParagraphStyle = myPStylesList[1];
Best,
Michel, from FRIdNGE
Copy link to clipboard
Copied
It is probably too late to edit your Head style and setup the Next Style as Body.
Try a script from Stephan Moebius
Copy link to clipboard
Copied
A very short way! …
var myParas = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements(),
P = myParas.length, p,
myPStylesList = ["Blue", "Red"]; // Names of the 2 Para Styles to be played!
for ( p = 0; p < P; p++ ) if ( myParas
.appliedParagraphStyle.name == myPStylesList[0] ) myParas[p+1].appliedParagraphStyle = myPStylesList[1];
Best,
Michel, from FRIdNGE
Copy link to clipboard
Copied
Hi Michel
That worked brilliantly. Thank you so much!
The final script was:
var myParas = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements(),
P = myParas.length, p,
myPStylesList = ["Heading 3", "Untabbed"];
for ( p = 0; p < P; p++ ) if ( myParas
.appliedParagraphStyle.name == myPStylesList[0] ) myParas[p+1].appliedParagraphStyle = myPStylesList[1];
Very best wishes to both you and Michael for the replies
Mark
Copy link to clipboard
Copied
Michel, nice!