Copy link to clipboard
Copied
I have some documents with a lot of paragraph styles that have been organized into groups. I have a simple script that is meant to ungroup these styles and delete the now-empty groups.
Code:
#target indesign
var myDoc = app.activeDocument;
if (myDoc.paragraphStyleGroups.length > 0)
{
myDoc.paragraphStyleGroups.everyItem().paragraphStyles.everyItem().move(LocationOptions.AT_END, myDoc);
myDoc.paragraphStyleGroups.everyItem().remove();
}
alert("Done")
The error I receive is (emphasis mine):
JavaScript Error!
Error Number: 30477
Error String: Invalid value for parameter 'reference' of method 'move'. Expected ParagraphStyle, ParagraphStyleGroup, CharacterStyle, CharacterStyleGroup, CellStyle, CellStyleGroup, TableStyle, TableStyleGroup, Document or Application, but received Document.
As you can see, my pickle is that my value is of an allowed type. This only happens in some documents, and there's nothing that obviously distinguishes those documents from the ones in which it works.
One thing I've noticed is that the error sometimes takes a while to appear (a minute or so), but none of the styles have been moved once I click OK. So, I don't know if it's specific to one style. I doubt it, only because other documents with the same style set work.
Can anyone shed any light on what this error could mean in this context? I definitely have an activeDocument, so what could cause a Document to not be a Document?
Any help much appreciated!
Hi,
It occurs when 2 or more styles have the same name, probably.
Jarek
Copy link to clipboard
Copied
Hi,
It occurs when 2 or more styles have the same name, probably.
Jarek
Copy link to clipboard
Copied
That was it, thanks. Didn't realize it was possible to have a style defined twice within a document.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more