Copy link to clipboard
Copied
I have created a catalog with many paragraph styles. I would like to export the copy that uses one of these styles (citation). Is it possible to export only text that is styled with the citation style?
Try this code snippet:
var styleName = "citation";
createXSL(styleName);
function createXSL(styleName){
var myDoc = app.documents[0];
if(myDoc.paragraphStyles.item(styleName).isValid){
app.findTextPreferences = NothingEnum.NOTHING;
app.findTextPreferences.findWhat = NothingEnum.NOTHING;
app.changeTextPreferences = NothingEnum.NOTHING;
app.changeTextPreferences.changeTo = NothingEnum.NOTHING;
app.findTextPreferences.appliedParagraphStyle = styleNa
...
Copy link to clipboard
Copied
Try this code snippet:
var styleName = "citation";
createXSL(styleName);
function createXSL(styleName){
var myDoc = app.documents[0];
if(myDoc.paragraphStyles.item(styleName).isValid){
app.findTextPreferences = NothingEnum.NOTHING;
app.findTextPreferences.findWhat = NothingEnum.NOTHING;
app.changeTextPreferences = NothingEnum.NOTHING;
app.changeTextPreferences.changeTo = NothingEnum.NOTHING;
app.findTextPreferences.appliedParagraphStyle = styleName;
var allFoundText = myDoc.findText();
var string = "";
var today = new Date();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
var xml = '<html xmlns:x="urn:schemas-microsoft-com:office:excel"><head><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>Error Messages</x:Name><x:WorksheetOptions><x:Panes></x:Panes></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml></head><body><table border="1px"><thead><tr><td><b>'+styleName+'</b></td></tr></thead><tbody></tbody></table></body></html>';
var file = new File(myDoc.filePath.fsName.replace(/\\/g,'/') +"/"+ myDoc.name.replace(/\.indd/g,'')+".xls");
var xml = new XML(xml);
for(var i = 0; i < allFoundText.length; i++){
for(var p = 0; p < allFoundText[i].paragraphs.length; p++){
var newChild = new XML("<tr><td>"+allFoundText[i].paragraphs[p].contents+"</td></tr>");
xml.body.table.tbody.appendChild(newChild);
}
}
file.encoding = 'UTF-8';
file.open('w');
file.write(xml.toXMLString());
file.close();
}
}
Best
Sunil
Copy link to clipboard
Copied
Thank you, Sunil.
Unfortunately, I have no idea where to place this snippet code OR how to start the export. ??? Can you share the process?
Greatly appreciated.
-bmw
Copy link to clipboard
Copied
https://creativepro.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-or-blog-post/
Run the script on an open doc. The xls will be saved to the same folder as the active document.
Copy link to clipboard
Copied
Thank you Brian—that did it!!
Thank you Adobe Community!
-bmw