Highlighted

[JS CS3] Find/Change "[Basic Paragraph]" style

Participant ,
Mar 11, 2008

Copy link to clipboard

Copied

I'm trying to find all occurances of the [Basic Paragraph] style and replace them with [No Paragraph Style]. I'm using:

app.findTextPreferences.appliedParagraphStyle = "[Basic Paragraph Style]";
app.changeTextPreferences.appliedParagraphStyle = "[No Paragraph Style]";

I get the message "Invalid value for set property 'appliedParagraphStyle'. Expected String, ParagraphStyle or NothingEnum enumerator, but received "[Basic Paragraph Style]"."

I've tried every combination of brackets, no brackets, quotes, no quotes, etc. It doesn't seem like this can be scripted, even though it can be done via find/change in InDesign. Am I banging my head against the wall? Does anyone know if this can be done?
TOPICS
Scripting

Views

1.0K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

[JS CS3] Find/Change "[Basic Paragraph]" style

Participant ,
Mar 11, 2008

Copy link to clipboard

Copied

I'm trying to find all occurances of the [Basic Paragraph] style and replace them with [No Paragraph Style]. I'm using:

app.findTextPreferences.appliedParagraphStyle = "[Basic Paragraph Style]";
app.changeTextPreferences.appliedParagraphStyle = "[No Paragraph Style]";

I get the message "Invalid value for set property 'appliedParagraphStyle'. Expected String, ParagraphStyle or NothingEnum enumerator, but received "[Basic Paragraph Style]"."

I've tried every combination of brackets, no brackets, quotes, no quotes, etc. It doesn't seem like this can be scripted, even though it can be done via find/change in InDesign. Am I banging my head against the wall? Does anyone know if this can be done?
TOPICS
Scripting

Views

1.0K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mar 11, 2008 0
Participant ,
Mar 11, 2008

Copy link to clipboard

Copied

"[Basic Paragraph]" as shown in the code below doesn't work either. (the word "Style" actually snuck in as I was trying different variations. But no combination seems to work.

If anyone knows that [Basic Paragraph] can or cannot be accessed via scripting, I'd like to know. Thanks.

app.findTextPreferences.appliedParagraphStyle = "[Basic Paragraph]";
app.changeTextPreferences.appliedParagraphStyle = "[No Paragraph Style]";

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 11, 2008 0
Enthusiast ,
Mar 11, 2008

Copy link to clipboard

Copied

Leave out the word "style" in Basic Paragraph Style. It should just say
"[Basic Paragraph]".

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 11, 2008 0
Adobe Community Professional ,
Mar 11, 2008

Copy link to clipboard

Copied

Keith,

You need this format:

app.findTextPreferences.appliedParagraphStyle =
app.activeDocument.paragraphStyles.item("[Basic Paragraph]")

For those two styles.

Peter

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 11, 2008 0
Explorer ,
Mar 11, 2019

Copy link to clipboard

Copied

What if I don't want to change the style I just want to find the basic paragraph style and then alert the user?

like:

if

(app.findTextPreferences.appliedParagraphStyle ==

app.activeDocument.paragraphStyles.item("[Basic Paragraph]") )

{ alert "you have basic paragraphs");}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 11, 2019 0
Adobe Community Professional ,
Mar 11, 2019

Copy link to clipboard

Copied

Try the following

app.findTextPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyles.itemByName("$ID/[Basic Paragraph]")

var res = app.documents[0].findText()

if(res.length != 0)

    alert("You have basic paragraphs")

-Manan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 11, 2019 1
Participant ,
Mar 11, 2008

Copy link to clipboard

Copied

Peter, thanks. Works like a charm!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 11, 2008 0