Possible to Remove, Then Load All Text Styles?
I'd like to remove all the Paragraph Styles and Character Styles from an InDesign CS4 document, and replace them with Paragraph Styles and Character Styles from another InDesign document. A search of this forum resulted in a similar discussion, http://forums.adobe.com/message/2919544 in which a script was utilized to remove all the text styles from a file. The script is shown below.
The script is a timesaver as is, but I was wondering if it could mofified to "Load All Text Styles" from a file path/InDesign document that I specify?
Thanks in advance for any ideas on this.
var myDoc = app.activeDocument;
var myParStyles = myDoc.paragraphStyles;
var myCharStyles = myDoc.characterStyles;
for (j = myParStyles.length-1; j >= 2; j-- ) {
removeUnusedParaStyle(myParStyles
}
for (i = myCharStyles.length-1; i >= 1; i-- ) {
removeUnusedCharStyle(myCharStyles);
}
function removeUnusedParaStyle(myPaStyle) {
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreferences.appliedParagraphStyle = myPaStyle;
var myFoundStyles = myDoc.findText();
if (myFoundStyles == 0) {
myPaStyle.remove();
}
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
}
function removeUnusedCharStyle(myChStyle) {
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreferences.appliedCharacterStyle = myChStyle;
var myFoundStyles = myDoc.findText();
if (myFoundStyles == 0) {
myChStyle.remove();
}
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
}