• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Exporting from InDesign to Excel...

New Here ,
Mar 01, 2021 Mar 01, 2021

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?

TOPICS
How to , Import and export , Scripting

Views

687

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Mar 01, 2021 Mar 01, 2021

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
...

Votes

Translate

Translate
Advocate ,
Mar 01, 2021 Mar 01, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 02, 2021 Mar 02, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 02, 2021 Mar 02, 2021

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 02, 2021 Mar 02, 2021

Copy link to clipboard

Copied

LATEST

Thank you Brian—that did it!!

 

Thank you Adobe Community!

-bmw

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines