2 Replies Latest reply on Oct 5, 2012 4:02 AM by bgfrhlp

    How to place one row from Excel at a time?


      Hello everyone,


      Actually the topic should be "How to set Excel import preferences?", but I am hesitant to change the old topic.


      The problem is that app.excelImportPreferences doesn't define the import preferences. The code ignores the setting of the Excel import preferences and uses previous preferences from InDesign. I tried changing the table formatting from InDesign. I have tried app.excelImportPreferences.rangeName = "A3:H3";.


      Below the code. Help appreciated!




      P.S. I have tried to locate help from the forum and the internet, with no success.



      doc = app.open(filePath = "d:/base.indt");

      newFrame = doc.textFrames.add({geometricBounds:[6,28,37,84]});

      setExcelImportPrefs ();

      excelFile = new File ("d/file.xlsx");

      newFrame.place (excelFile);


      function setExcelImportPrefs(){


              alignmentStyle = AlignmentStyleOptions.spreadsheet;

              decimalPlaces = 4;

              preserveGraphics = true;

              //Enter the range you want to import as "start cell:end cell".

              rangeName = "A3:H3";

              sheetIndex = 1;

              showHiddenCells = false;

              tableFormatting = TableFormattingOptions.excelFormattedTable;

              useTypographersQuotes = false;

              viewName = "";




      Message was edited by: bgfrhlp

        • 1. Re: How to place one row from Excel at a time?
          bgfrhlp Level 1

          One obvious solution to the problem is to import all information from the Excel file at once and edit it in InDesign with a script.


          doc = app.open(filePath = "d:/base.indt");

          newFrame = doc.textFrames.add();

          excelFile = new File ("d:/file.xlsx");

          newFrame.place (excelFile);

          excelData = newFrame.contents;

          arrExcelData = excelData.split("\t");



          P.S. How to fire the placegun? With app.place(); I get a loaded placegun, but I cannot find a way to fire it with a script.

          • 2. Re: How to place one row from Excel at a time?
            bgfrhlp Level 1

            The code works well with old Excel files (.xls, Mac OS X). Maybe Adobe should do some updating...


            P.S. Today I filed a bug report.


            P.S.S. Works also in Windows 7 with .xls-files.


            Message was edited by: bgfrhlp