Skip to main content
dublove
Legend
July 22, 2026
Answered

Why does copying cell styles not support inheriting parent data?

  • July 22, 2026
  • 2 replies
  • 39 views

 

This seems different from the object style, there is no Reset to base option here.
The following code only copied an empty style B and did not inherit the data from A.

    var baseSty = app.documents[0].cellStyles.itemByName('A');
//alert(baseSty.parent);
//exit();

newSty = baseSty.duplicate();
newSty.name = 'B';
newSty.basedOn = baseSty;

But you commented out this line:

//newSty.basedOn = baseSty;


Discovered that B can inherit A's data, but based on 'none'

 

Manual operation also has the same effect.
This may be the difference between manual "direct copying" and "based on new creation".
I don't know why they can't have both?

 

    Correct answer rob day

    Discovered that B can inherit A's data, but based on 'none'

     

    var baseSty = app.documents[0].cellStyles.itemByName('A');
    var newSty = baseSty.duplicate();
    newSty.name = "B";
    $.writeln(newSty.basedOn.name)
    //returns "MyBase"

     

    Before:

     

     

    After:

     

     

    2 replies

    rob day
    Community Expert
    rob dayCommunity ExpertCorrect answer
    Community Expert
    July 22, 2026

    Discovered that B can inherit A's data, but based on 'none'

     

    var baseSty = app.documents[0].cellStyles.itemByName('A');
    var newSty = baseSty.duplicate();
    newSty.name = "B";
    $.writeln(newSty.basedOn.name)
    //returns "MyBase"

     

    Before:

     

     

    After:

     

     

    dublove
    dubloveAuthor
    Legend
    July 22, 2026

    Hi ​@rob day 

    MyBase is the most basic setting, which is equivalent to '[None]'
    My initial idea was:
    A is based on MyBase (which is not a concern now), and then B is based on A.
    Can't B be based on A? Do I need to inherit A's settings at the same time?

    dublove
    dubloveAuthor
    Legend
    July 22, 2026

    Using 'directly copying style' in the upper right corner is effective.

    But it seems that once "newSty. basedOn=baseSty;" is used in the future
    The data becomes empty.