Skip to main content
Inspiring
December 14, 2011
Answered

remove cell style - preserve formatting

  • December 14, 2011
  • 1 reply
  • 1927 views

Hello Scripters,

Is it possible to preserve the formatting, when I remove an applied cell style with the following code?

     “MyCellStyle.remove(app.activeDokument.cellStyles.firstItem());”

How can I get access to this feature in my script? (see also screenshot->red arrow)

Thanks for hints.

Roland

This topic has been closed for replies.
Correct answer Laubender

The problem is this:

I want to convert the formatting from one cell to another (in a different table). After this, the formatting of the new cell should be retained, but the cell Style is to be deleted. 

So I remove the generated cell style and replace it with cellStyle:[None] but there is also no option to reserve formatting via script.

For ChararacterStyle it’s the same: there is no option like in the GUI

void remove([replacingWith: CharacterStyle])

Now I try to work with the properties of the cell.

Kind regards

Roland


Roland:
You could iterate through all your cells with the applied cell style, select the cells one after another and apply a menu action to break the link to the style ("Break Link to Style" / "Verknüpfung mit Format aufheben").

Then you can remove the cell style without loosing any formatting.

To invoke the menu action you could use this code. For security reasons I wrapped it up with a "try/catch":

//Disconnect the cell with the applied cell style (option in the cell styles panel of the UI: "Break Link to Style" / "Verknüpfung mit Format aufheben"):

try{app.scriptMenuActions.itemByID(132129).invoke()}catch(e){};


Uwe

1 reply

Harbs.
Legend
December 14, 2011

It looks to me like it's missing. File a feature request...

To simulate the funtionality, you'll probably have to grab the properties of the style, and then loop through the doc, find every cell that has the style applied, and apply the styling manually...

Good luck!

Harbs

Inspiring
December 14, 2011

I already feared it. Well, I must try another way.

Many thanks for your answer.

Kind regards

Roland

TᴀW
Legend
December 14, 2011

I've haven't tried this or even looked into it, but last week when I was

trying to remove a character style from text and retain formatting, the

answer was to apply the style (which does not remove formatting)

first.

So maybe try applying No Cell Style?

Ariel

id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators