Skip to main content
Inspiring
March 30, 2023
Answered

how to alert user for overridden CellStyle in indesign using javascript

  • March 30, 2023
  • 5 replies
  • 1068 views

I tried but there is only way to clearCellOverrides but I don't  see any method to point CellOverrides. Help me with this point!

This topic has been closed for replies.
Correct answer Karthik SG
  var tables = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
  for (var j = 0; j < tables.length; j++) {
    var cells = tables[j].cells.everyItem().getElements();
    for (var k = 0; k < cells.length; k++) {
          cells[k].select();
           var clearOverridesCmd = app.menuActions.itemByID(132128);
            if (clearOverridesCmd.enabled) {            
                  var OverCellObject = {
                  cellContent:  cells[k].contents,
                  CellpageNo: cells[k].parent.parent.parentPage.name,
                  cellStyleName:  cells[k].appliedCellStyle.name
                };
             myCellOverrides.push(OverCellObject);
            } 
    }
  }

I tried like this and it was working fine for me! Thanks for your response and efforts @Peter Kahrel and @Manan Joshi 

5 replies

Peter Kahrel
Community Expert
Community Expert
April 26, 2023

Very clever, @Karthik SG .

Inspiring
May 11, 2023

Thanks @Peter Kahrel 

Karthik SGAuthorCorrect answer
Inspiring
April 22, 2023
  var tables = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
  for (var j = 0; j < tables.length; j++) {
    var cells = tables[j].cells.everyItem().getElements();
    for (var k = 0; k < cells.length; k++) {
          cells[k].select();
           var clearOverridesCmd = app.menuActions.itemByID(132128);
            if (clearOverridesCmd.enabled) {            
                  var OverCellObject = {
                  cellContent:  cells[k].contents,
                  CellpageNo: cells[k].parent.parent.parentPage.name,
                  cellStyleName:  cells[k].appliedCellStyle.name
                };
             myCellOverrides.push(OverCellObject);
            } 
    }
  }

I tried like this and it was working fine for me! Thanks for your response and efforts @Peter Kahrel and @Manan Joshi 

Peter Kahrel
Community Expert
Community Expert
April 1, 2023

Aha -- thanks, @Manan Joshi  I misread that. Well, finding (cell) style overrides isn't so easy. Text-style overrides can be displayed, but to collect cells with overridden style isn't so easy.

 

Instead of checking whether there are style overrides, maybe clear all overrides. Is that a possibility?

 

P.

Community Expert
April 2, 2023

Thanks for confirming @Peter Kahrel, to be honest I was expecting that you would pull out a rabbit from your hat and I would be amazed as always. With this cleared out we need to see what the OP is after, only that would tell us if clearing the overrides would work or not. Another trick that I used in the past for paragraph/character styles is to export the tagged text and then parse it to find the properties that had the overrides applied over it. Not sure if it would work with cell styles, probably not but that remains to be seen.

-Manan

-Manan
Peter Kahrel
Community Expert
Community Expert
March 31, 2023

This script alerts you when there are overset cells in a document:

if (app.documents[0].stories.everyItem()
   .tables.everyItem()
   .cells.everyItem()
   .overflows.join('').indexOf('true') >= 0) {
      alert ('There are overset cells in the document.');
}

I know what your next question will be.

Community Expert
April 1, 2023

Hi Peter,

The OP asked for cellstyle override you alerted overset. So as you mentioned you already know the question, please be kind enough to explain it 🙂

-Manan

-Manan
Inspiring
March 31, 2023

is there anyway to indicate cellOverrides is present in document??

 

Peter Kahrel
Community Expert
Community Expert
April 1, 2023

--