Sample of how to load styles from indd-file to document or app: #target InDesign var myFolder = Folder('C:/path/to/Folder/with/Indd-Files'); var allStyleFiles = myFolder.getFiles("*.indd"); var arrayOfStyleFileNames = []; for(var myIndex = 0; myIndex < allStyleFiles.length; myIndex++ ){arrayOfStyleFileNames.push(allStyleFiles[myIndex].name)} var selectedStyleFile = chooseStyleFile (arrayOfStyleFileNames) function chooseStyleFile(arrayOfStyleFileNames){ var myDialog = app.dialogs.add({name:"Optionale Formatdateien", canCancel:true}); with(myDialog){ with(dialogColumns.add()){ with(borderPanels.add()){ with(dialogColumns.add()){ staticTexts.add({staticLabel:"Bitte eine Formatdatei wählen:"}); } with(dialogColumns.add()){ var pickedStyle = dropdowns.add({stringList:arrayOfStyleFileNames, selectedIndex:0}); } } } } if(myDialog.show() == true){ var pickedStyle = pickedStyle.selectedIndex; myDialog.destroy(); return File(myFolder.toString() + '/' + arrayOfStyleFileNames[pickedStyle]) } else{ myDialog.destroy() exit(); } } if(app.documents.length == 0){ try{ RemoveIdStyles(); app.importStyles (ImportFormat.PARAGRAPH_STYLES_FORMAT, selectedStyleFile, GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE) app.importStyles (ImportFormat.CHARACTER_STYLES_FORMAT, selectedStyleFile, GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE) app.importStyles (ImportFormat.OBJECT_STYLES_FORMAT, selectedStyleFile, GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE) app.importStyles (ImportFormat.TABLE_STYLES_FORMAT, selectedStyleFile, GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE) app.importStyles (ImportFormat.CELL_STYLES_FORMAT, selectedStyleFile, GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE) app.importStyles (ImportFormat.TABLE_AND_CELL_STYLES_FORMAT, selectedStyleFile, GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE) app.loadSwatches (selectedStyleFile) delEmptyParStyleGroups(); alert("Die Formate für " + selectedStyleFile.name + " wurden geladen.") }catch (e){ alert ("Folgender Fehler trat auf: " + e) } } if(app.documents.length != 0){ try{ app.activeDocument.importStyles (ImportFormat.PARAGRAPH_STYLES_FORMAT, selectedStyleFile, GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE) app.activeDocument.importStyles (ImportFormat.CHARACTER_STYLES_FORMAT, selectedStyleFile, GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE) app.activeDocument.importStyles (ImportFormat.OBJECT_STYLES_FORMAT, selectedStyleFile, GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE) app.activeDocument.importStyles (ImportFormat.TABLE_STYLES_FORMAT, selectedStyleFile, GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE) app.activeDocument.importStyles (ImportFormat.CELL_STYLES_FORMAT, selectedStyleFile, GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE) app.activeDocument.importStyles (ImportFormat.TABLE_AND_CELL_STYLES_FORMAT, selectedStyleFile, GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE) app.activeDocument.loadSwatches (selectedStyleFile) delEmptyParStyleGroups(); alert("Die Formate für " + selectedStyleFile.name + " wurden nachgeladen.") }catch (e){ alert ("Folgender Fehler trat auf: " + e) } } //Formate in InDesign löschen function RemoveIdStyles(){ var _pS = app.allParagraphStyles; for (var i=0; i<_pS.length; i++) { try { _pS.remove(); } catch (e) { } } var _cS = app.allCharacterStyles; for (var i=0; i<_cS.length; i++) { try { _cS.remove();} catch (e) { } } var _pS = app.allObjectStyles; for (var i=0; i<_pS.length; i++) { try { _pS.remove(); } catch (e) { } } var _pS = app.swatches; for (var i=1; i<_pS.length; i++) { try { _pS.remove(); } catch (e) { } } } //Leere Formatgruppen löschen function delEmptyParStyleGroups(){ var pGroups = app.paragraphStyleGroups; for(var z=pGroups.length -1; z >=0; z--){ if(pGroups .allParagraphStyles.length <= 0){ pGroups .remove(); } } }
... View more