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

Exporting Character style and Page Reference to Excel file

Explorer ,
Nov 13, 2023 Nov 13, 2023

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!

TOPICS
How to , Scripting , Type
270
Translate
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

Community Expert , Nov 13, 2023 Nov 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
...
Translate
Community Expert ,
Nov 13, 2023 Nov 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.

 

Translate
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 ,
Nov 13, 2023 Nov 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. 

Translate
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
Explorer ,
Nov 14, 2023 Nov 14, 2023
LATEST

This. Wow. 

Thank you very much!

Truly above helpful. 

Shawn

Translate
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