Skip to main content
Inspiring
March 10, 2020
Answered

Accessing Excel data from Indesign CS6 with js

  • March 10, 2020
  • 3 replies
  • 2331 views

Hi,

 

I need to read Excel data from Indesign CS6 with js. And what I found so far is not working:

 

readData(x,y);

// https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/783724f0-526d-4c1d-a565-ebcdbca83cb8/how-to-read-excel-file-using-javascript?forum=sidebargadfetdevelopment
function readData(x,y){

var excel=new ActiveXObject("Excel.Application");
excel.Workbooks.Open(myFilePath);
//var excel.workbooks.open(myFolderPath);
var data = excel_sheet.cells(x,y).value; //x,y consider the coordinate of row and column or the data
alert (data)
return data;
}

 

Thank you for your help

Yulia

    This topic has been closed for replies.
    Correct answer Kasyan Servetsky

    Hi Yulia,

    I updated the function so it works with InDesign 2020 for Mac now. Please, re-download it.

    — Kas

    3 replies

    Kasyan Servetsky
    Legend
    March 10, 2020
    Inspiring
    March 11, 2020

    Hi everybody,

     

    Thank you for your help.

     

    Kasyan,


    I am on a Mac, I am using your mac version, I entered my Excel file path into your script and running it in open indesign document. It returns correct path, so it should be finding the file.

    My Excel file is very simple for now. Only one sheet, a title row and couple of rows with 4 columns of data.

    When I run your script, it stops at applescript doScript line. The error message tells me that 'it can't get sheet 1 of missing value'. What is it that I am missing?

     

     

    Thank you

    Yulia

    Kasyan Servetsky
    Legend
    March 11, 2020

    Could you send me the Excel file for testing? I have no idea why it ain't working. Maybe you are on a more recent version? (i am on Excel 2016).

    My e-mail is askoldich [dot] yahoo [dot] com

    — Kas

    Michael Bullo
    Community Expert
    Community Expert
    March 10, 2020

    This doesn't directly answer your question at all but could you use Data Merge within InDesign to pull in this Excel data?

    ajabon grinsmith
    Community Expert
    Community Expert
    March 10, 2020

    The code posted on the site you referred to is Javascript that runs on HTML and cannot be used in InDesign at all.

    I tried searching on Google.
    https://stackoverflow.com/questions/24946883/how-to-set-excel-import-preferences-in-indesign-cs6-using-extendscript