Skip to main content
dublove
Legend
December 25, 2024
Question

How to streamline this script and disable any popup prompts.

  • December 25, 2024
  • 2 replies
  • 447 views

Hello, everyone.

How to streamline this script and disable any popup prompts.

Thank you very much.

 

 

// Clear All Overrides
// Written by TAW. (c) 2014 by Bookraft Solutions, Israel (Id-Extras.com)
// Please do not delete this copyright notice.
//

var myOverrideType = OverrideType.ALL;
// var myOverrideType = OverrideType.CHARACTER_ONLY;
// var myOverrideType = OverrideType.PARAGRAPH_ONLY;

var allStories = app.activeDocument.stories.everyItem();

// Remove overrides from all stories
try{
allStories.clearOverrides(myOverrideType);
}
catch (e){alert ("No stories!")}

// Remove overrides from all footnotes
try{
allStories.footnotes.everyItem().texts.everyItem().clearOverrides(myOverrideType);
}
catch (e){alert ("No footnotes!")}

// Remove overrides from all table
try{
allStories.tables.everyItem().cells.everyItem().paragraphs.everyItem().clearOverrides(myOverrideType);
}
catch (e){alert ("No tables!")}

alert("Overrides cleared!");
// Remove overrides from all cells
try{
allStories.tables.everyItem().cells.everyItem().clearCellStyleOverrides(true);
}
catch (e){alert ("No tables!")}

 

 

This topic has been closed for replies.

2 replies

Peter Kahrel
Community Expert
Community Expert
December 26, 2024

The script has a notice at the top:

Written by TAW. (c) 2014 by Bookraft Solutions, Israel (Id-Extras.com)

 You should write to TAW (Ariel Walden), the web address is there.

Community Expert
December 27, 2024

Hi @Peter Kahrel

Writing to the original author is always the first thing to consider. However, the OP seemed to have a very simple ask not related to the script in question and @Robert at ID-Tasker did answer it. The thing that bothered me is a terse statement that it does not work and then a code snippet. Very difficult to understand and help. It's like spending your own time to first make sense of the little information supplied and then come up with a suggestion that may or may not help. Tough task. I am pretty sure Ariel would also not be able to help with the ask here 🙂

-Manan

-Manan
Robert at ID-Tasker
Legend
December 25, 2024

You need to add this:

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;

at the beginning.

 

Then this - at the end:

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

 

dublove
dubloveAuthor
Legend
December 26, 2024

I merged it, but for some reason it didn't work as well as the sentence-by-sentence.

try{
	// Remove overrides from all stories
	allStories.clearOverrides(myOverrideType);
	// Remove overrides from all footnotes
	allStories.footnotes.everyItem().texts.everyItem().clearOverrides(myOverrideType);
	// Remove overrides from all table
	allStories.tables.everyItem().cells.everyItem().paragraphs.everyItem().clearOverrides(myOverrideType);
	// Remove overrides from all cells
	allStories.tables.everyItem().cells.everyItem().clearCellStyleOverrides(true);
	}
	catch (e){}
	

 

Community Expert
December 26, 2024

Can you please elaborate what did not work? it Did you add the lines @Robert at ID-Tasker gave and you still see alerts and popups? Or does the original script not perform as you want it to?

-Manan

-Manan