Script to remove paragraph space before/after
Hi! Looking for scripting help from the experts. I have to format lots of long documents with several heading styles and am looking for a way to apply local formatting to a heading depending on what follows. (Heading styles have space after so they are separated from body copy, however, if another heading follows, it looks better if that space is reduced - this is where some conditional javascript formatting might help).
I need a script that can look for all Heading 1 followed by Heading 2, and then remove the after paragraph spacing from Heading 1. And so on with a Heading 3 that follows Heading 2, etc. I have enough knowledge to write all the variations but I am having trouble finding a starting point for this script, if there's a way to do it at all. I'm sure there is. Basically, it needs to look for all Paragraph Style X, and if that is followed by Paragraph Style Y, then set spacing after paragraph to 0. Can anyone here help?
Thank you!!