Skip to main content
dublove
Legend
July 2, 2025
Answered

How to create new "None" character  paragraph  table cell and object styles with scripts?

  • July 2, 2025
  • 2 replies
  • 213 views

There are too many different properties settings.

I want to get a controlled, clean style with no overrides.
Is there an easy way to do it in three or two lines?

 

Thank you very  much.

Correct answer rob day

Text objects also has the clearOverrides() method—this would clear the overrides from selected text

 

//some selected text—Text, Paragraohs, Characters etc.
var sel = app.activeDocument.selection[0];
//could also be OverrideType.CHARACTER_ONLY or OverrideType.PARAGRAPH_ONLY
sel.clearOverrides(OverrideType.ALL)

2 replies

rob day
Community Expert
Community Expert
July 2, 2025

Hi @dublove , The function I’ve posted for you in the past uses the default on creation—based on [No Paragraoh Style]—then you set the properties you want to change in the propertie = {} line:

 

//create a default paragraph style
var pStyle = makeParaStyle(app.activeDocument, "MyStyle")
//changed properties from the default
pStyle.properties = {fillColor:"Black", fillTint:50}


/**
* Makes a new named ParagraphStyle 
* @ param the document to add the style to 
* @ param style name 
* @ return the new paragraph style 
*/

function makeParaStyle(d, n){
if (d.paragraphStyles.itemByName(n).isValid) {
return d.paragraphStyles.itemByName(n);
 } else {
return d.paragraphStyles.add({name:n});
 }
}

 

 

rob day
Community Expert
rob dayCommunity ExpertCorrect answer
Community Expert
July 2, 2025

Text objects also has the clearOverrides() method—this would clear the overrides from selected text

 

//some selected text—Text, Paragraohs, Characters etc.
var sel = app.activeDocument.selection[0];
//could also be OverrideType.CHARACTER_ONLY or OverrideType.PARAGRAPH_ONLY
sel.clearOverrides(OverrideType.ALL)
creative explorer
Community Expert
Community Expert
July 2, 2025

@dublove one of the easiest way to see if you have any styles that have 'overrides' is by toggling the 'highlighter' 

Once you see an override, select that override and create a new style from it.

m
dublove
dubloveAuthor
Legend
July 2, 2025

Hi creative explorer.

It's not that, it's that I often have to use the code in scripts.
Looking for some simple code.