Can a paragraph style, character style, table style and cell style be applied with one click?

Explorer ,
Apr 08, 2021 Apr 08, 2021

Copy link to clipboard

Copied

-------------------------------------------------------------------------------------------

Sorry, I asked a similar question, but I didn't explain it clearly at that time.

At that time, a teacher gave the script, but the script was too slow to apply.

-------------------------------------------------------------------------------------------

After I import word text, I need to apply paragraph style (for example: Zw) and "None" character style to all text.

Here's a problem to deal with: sometimes you have to perform "clear priorities(clear preferences)".

Only in this way can the style application be effective.

 

The table applies the table style (for example: tab) and the none cell style.

Same problem: sometimes you have to perform table style > clear preferences; cell style > clear preferences.

 

Now, what I want to ask for help is: whether the above operation can be realized with one click script.

The example file used is here

 

CLEAR-1.jpgCLEAR-2.jpg

 

 

Best wishes

 

 

TOPICS
Bug, Feature request, How to, Import and export, Scripting

Views

108

Likes

translate

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
community guidelines
Adobe Community Professional ,
Apr 09, 2021 Apr 09, 2021

Copy link to clipboard

Copied

You can clear overrides from entire document of Paragraph Styles, Character Styles, Table Styles & Cell Styles with this snippet :

//===================================
var allStories = app.documents[0].stories.everyItem();
allStories.clearOverrides(OverrideType.ALL);
allStories.tables.everyItem().clearTableStyleOverrides(true);
allStories.tables.everyItem().cells.everyItem().clearCellStyleOverrides(true);
//===================================

Best

Sunil

Likes

translate

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
community guidelines
Contributor ,
Apr 09, 2021 Apr 09, 2021

Copy link to clipboard

Copied

From the Object Model Viewer: Text.applyParagraphStyle (using: ParagraphStyle , clearingOverrides: Boolean )

In other words, assume you have selected some text (your script should verify that):

app.selection[0].applyParagraphStyle(pStyle, true);

where pStyle is a reference (not just the name) of an existing paragraph style. Apparently clearingOverrides defaults to true but I'm in the habit of always specifying it.

You might see examples saying something like text.appliedParagraphStyle = pStyle but that doesn't give you the option of clearing overrides at the same time. Also note, that clearingOverrides doesn't do anything about any character styles already applied. So you may want to add a line to set the appliedCharacterStyle to [None].

Hope this helps,

Bob

 

Likes

translate

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
community guidelines
Explorer ,
Apr 09, 2021 Apr 09, 2021

Copy link to clipboard

Copied

Is it possible to target the currently selected content or text frame?

How to write the paragraph style of "ZW" directly?

Best wishes

Likes

translate

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
community guidelines