Skip to main content
Inspiring
November 13, 2023
Answered

Exporting Character style and Page Reference to Excel file

  • November 13, 2023
  • 2 replies
  • 409 views

Hello brains of InDesign...

 

I have a 40 pg document that has a whole series of products listed in it - upwards of 400 products. Each product has a product number that is setup in its own character style. I was asked if we can export an excel file that shows the product number and the page it's on. Is there a simple way of doing this? I believe there may be a script to run, but i have no idea where to find something so specific like this. 

 

Any help?

Thanks!

This topic has been closed for replies.
Correct answer brian_p_dts

Here is a JSX simplistic script that should do what you need.

app.findTextPreferences = null;
app.findTextPreferences.appliedCharacterStyle = "Your Style Name";
var fs = app.activeDocument.findText();
var a = [];
var pp;
for (var i = 0; i < fs.length; i++) {
    try {
        pp = fs[i].parentTextFrames[0].parentPage.name;
    } catch(e) {
        //textframe probably in pasteboard
        pp = "PB";
    }
    a.push(fs[i].contents + "," + pp);
}

var f = File(Folder.desktop + "/sku-log.csv");
f.encoding = "UTF-8";
f.open("w");
f.writeln(a.join("\n"));
f.close();
alert("Fin");

 Run it on the open doc. Change the character style name to the one you want to target, leaving the quotes.  It will save a sku-log.csv file out to your desktop. 

2 replies

brian_p_dts
Community Expert
brian_p_dtsCommunity ExpertCorrect answer
Community Expert
November 13, 2023

Here is a JSX simplistic script that should do what you need.

app.findTextPreferences = null;
app.findTextPreferences.appliedCharacterStyle = "Your Style Name";
var fs = app.activeDocument.findText();
var a = [];
var pp;
for (var i = 0; i < fs.length; i++) {
    try {
        pp = fs[i].parentTextFrames[0].parentPage.name;
    } catch(e) {
        //textframe probably in pasteboard
        pp = "PB";
    }
    a.push(fs[i].contents + "," + pp);
}

var f = File(Folder.desktop + "/sku-log.csv");
f.encoding = "UTF-8";
f.open("w");
f.writeln(a.join("\n"));
f.close();
alert("Fin");

 Run it on the open doc. Change the character style name to the one you want to target, leaving the quotes.  It will save a sku-log.csv file out to your desktop. 

TuuluuwagAuthor
Inspiring
November 14, 2023

This. Wow. 

Thank you very much!

Truly above helpful. 

Shawn

Willi Adelberger
Community Expert
Community Expert
November 13, 2023

3rd party developer created plugin ins to connect to data bases and Excel. Some of them allow 2-ways, from the DB to InDesign and if you make changes or add something back to the DB. Search for DB connections to InDesign. Those Plugins are not cheap, but useful.