Indesign Script for placing excel-file

Hi all, I'm new to Indesign Scripting, and I'm hoping someone can help me with the following code:
All I want to do is:
open indesign file
open excel file
place excelfile as a table (with flow enabled)
save document & export as PDF
Thanks!
//Define file to open
var myDocumentFile = new File("/d/Projecten/Indesign Server/document.indd");
//Define file to save
//var mySaveFile = new File("/d/Projecten/Indesign Server/document_save.indd");
//Define file to export
var exportPDF = new File("/d/Projecten/Indesign Server/document_save.pdf");
//Open xls-file to place as table
var myExcelFile = new File ("/d/Projecten/Indesign Server/products.xls");
var result = "";
if(!myDocumentFile.exists) {
    result = "Unable to find DOCUMENT:  " + myDocumentFile.path;
    $.writeln(result);
    exit();
} else if(!myExcelFile.exists) {
    result = "Unable to find EXCEL:  " + myDocumentFile.path;
    $.writeln(result);
    exit();
} else {
    // Open file
    var myDocument = app.open(myDocumentFile);
    with(app.documents.item(0).pages.item(0)){
        myTarget = textFrames.item("tabel");
    var myPage = myDocument.pages.item(0);
    //Set excel placement properties
    setXLimportPrefs();
    // Place Excel file
       try {
             $.writeln("Place Excel file");
            //HELP!! HOW TO PLACE EXCEL FILE?
            //myTextFrame.place(myFile);
        catch (e) {
             $.writeln("Place Excel file "  + e + " " + app.excelImportPreferences.errorCode);
            myDocument.close();
            exit();
    if(!exportPDF.parent.exists && !exportPDF.parent.create()) {
        result = "Not exported.  Unable to create the folder:  " + exportPDF.parent.fullName;
        $.writeln(result);
    } else {
        app.documents.item(0).exportFile(ExportFormat.pdfType, exportPDF, app.pdfExportPresets.item("[Press Quality]"));
    myDocument.exportFile(ExportFormat.PDF_TYPE,exportPDF);
    myDocument.close();
function setXLimportPrefs(){    $.writeln("setXLimportPrefs()");
        with(app.excelImportPreferences){
            //alignmentStyle property can be:
            //AlignmentStyleOptions.centerAlign
            //AlignmentStyleOptions.leftAlign
            //AlignmentStyleOptions.rightAlign
            //AlignmentStyleOptions.spreadsheet
            alignmentStyle = AlignmentStyleOptions.spreadsheet;
            decimalPlaces = 4;
            preserveGraphics = true;
            //Enter the range you want to import as "start cell:end cell".
            rangeName = "A1:B16";
            sheetIndex = 1;
            sheetName = "Appetizers";
            showHiddenCells = false;
            //tableFormatting property can be:
            //TableFormattingOptions.excelFormattedTable
            //TableFormattingOptions.excelUnformattedTabbedText
            //TableFormattingOptions.excelUnformattedTable
            tableFormatting = TableFormattingOptions.excelFormattedTable;
            useTypographersQuotes = true;
            viewName = "";
result;

"I just loaded a table into a text frame but it still contains nothing". I wonder how I'd check that, actually.
@Jongware:
To prevent this situation you could set the max. allowed cell height below your min. text frame height.
If this is not applicable, because in some situations you cannot know the usable text frame height beforehand, you can iterate through all your set rows and check if the parentTextFrames[0].parentPage.name property of the first insertionPoint of its first cell is defined. If it's undefined and your last text frames parentPage.name is not equal to the last defined parentPage.name of your check your table will remain overset.
Thinking about that method I must admit, that you can get a false positive, if a text wrap object on an applied master page comes into play…
So no, I see no fail-safe check for this situation.
Uwe

Similar Messages

  • Open data set for reading excel file on application server in back ground

    open data set for reading excel file on application server in back ground

    hi Vijay,
    I am afraid you won't be able to read from Excel file on Appl. Server.
    ec

  • Customised module for reading Excel files.

    Hi Gurus,
    I have to develop a customsed java module for reading Excel files from PI. I downloaded NWDS 7.31 from following location NWDS Download links - Java Development - SCN Wiki. I have installed it on my local laptop. For developing the module I need following Jar files.
    com.sap.aii.af.ms.svc_api
    com.sap.aii.proxy.svc_api.jar
    com.sap.aii.sec.svc_api.jar
    com.sap.aii.utilxi.server.jar
    com.sap.aii.utilxi.core.jar
    com.sap.xi.mapping.tool.lib_api.jar
    sap.com~tc~bl~txmanagerimpl~plb~impl.jar
    sap.com~tc~je~appcontect_api~API.jar
    com.sap.aii.af.cpa.svc.api
    com.sap.aii.af.lib.mod
    com.sap.aii.af.ms.ifc_api
    com.sap.aii.af.svc_api
    com.sap.xpi.ib.mapping.lib
    1. Where can i get these jar files. I checked these files in my downloaded NWDS 7.31  package, but cold not find them.
    Thanks in advance

    Hi.
    Check this thread.
    Where to get the libraries for XI development - Process Integration - SCN Wiki
    Regards
    Lucho

  • Java API for reading Excel Files.

    Hi,
    Can you please suggest me any api for reading excel files.
    Right now i am using jxl.jar for this purpose but i am searching for an open source java api better than this.
    Whether POI gives better than this ?
    Thanks,
    Amit Shah.

    Can you please suggest me any api for reading excel
    files.
    Right now i am using jxl.jar for this purpose
    but i am searching for an open source java api better
    than this.
    Whether POI gives better than this ?i don't know about jxl but poi has several features which an excel can contain and it has been vastly improved in the past few versions.

  • Need  Shell Script  for picking the files

    Hi,
        I want to write a shell script for piking the files in a sequence order (according to filename with time stamp)  from the sorce FTP server ..
                     Requirement is  in the source directory I'm getting files (Jain_1.xml  , Jjain_2.xml, Jain_3.xml .. ect..)  at  present my file adapter is picking all the files at a time  but  i want to pick  one by one... that to first i want to Jain_1.xml  after finish the processing of the file then only my file adapter should  pick the next file ( Jain_2.xml )  .
                  so..  all the forum mates suggest me to write a shell script..  but where  i have to write the s hell script. and where i have to deploy this script.... my Xi is running on UNIX ... so please sugest me  the procedure ...
    Regards
    Jain

    Hi,
    Why dont you use the option EOIO in which files will be picked up in order and will be proccessed in sequence....one after another....
    Regards,
    Sreeni.

  • Need Help Creating A Script For Labeling Finder Files from Indesign

    Trying to figure out a way to have a script run in InDesign CS4 that will label a text file RED after it's been imported into InDesign.
    We import numerous text files into an InDesign template. Since there are several text files in the same folder, we need to somehow "mark off" that we've imported that file and move to the next one to import. I have created an Automator "service" with a keyboard shortcut to label the file Red in the finder but it would be great if we could have this happen automatically after we import into InDesign.
    If we import the wrong text file by accident and it gets missed in proofing, it costs us a lot of money with the printer.
    Thanks for any ideas.
    Jim

    You know, these guys are absolutely right in their assessment that this is a good place for event listeners. You would need three scripts though.
    Something like...
    Label Placed Files Red.scpt
    --Put this in a folder called IDScripts in your Documents folder
    main(evt)
    on main(myEvent)
    tell application "Adobe InDesign CS4"
    set placedFilePath to full name of myEvent
    set placedFilePath to placedFilePath as alias
    end tell
    tell application "Finder"
    --This turns the file color red
    set label index of placedFilePath to 2
    end tell
    end main
    And these two are in your InDesign scripts folder...
    Start Placed File Finder Labelling.scpt
    --Installs the afterImport event listener for the Label Placed Files Red script.
    tell application "Adobe InDesign CS4"
    set myHandler to path to documents folder
    set myScriptName to "Label Placed Files Red.scpt"
    set myHandler to "" & myHandler & "IDScripts:" & myScriptName
    try
    set myHandler to myHandler as alias
    make event listener with properties {event type:"afterImport", handler:myHandler, captures:true}
    display dialog "Placed File Labelling: ON" buttons "OK" default button 1
    on error
    display dialog "ERROR: Couldn't start handler!" & return & return & "Make sure the \"" & myScriptName & "\" script in a folder called \"IDScripts\" inside your Documents folder and try again" buttons "OK" default button 1
    end try
    end tell
    Stop Placed File Finder Labelling.scpt
    --Removes the afterImport event listener for the Label Placed Files Red script.
    tell application "Adobe InDesign CS4"
    set myHandler to path to documents folder
    set myScriptName to "Label Placed Files Red.scpt"
    set myHandler to "" & myHandler & "IDScripts:" & myScriptName
    set myHandler to myHandler as alias
    set myResult to remove event listener event type "afterImport" handler myHandler with captures
    if (myResult is false) then
    display dialog "ERROR: Couldn't remove handler! Are you sure it is active?" & return & return & "If so, please quit and relaunch InDesign to get rid of it." buttons "OK" default button 1
    else
    display dialog "Placed File Labelling: OFF" buttons "OK" default button 1
    end if
    end tell

  • Script to open excel files take info and put into new document

    Hi All
    I am new to applescript, but looking through the forums it seems to be the solution to my problem.
    I have large numbers of excel files on a pc server which i want to open, take approx 8 cells of information from each and place into a new excel doc, forming a list. I want this if possible to happen automatically, so if a new excel document is placed into a folder on the server, the relavent information is added to my list.
    I have looked at automator but dont think it works with excel yet, and the programming in excel is too much for me.
    I posted a query here in my previous job for a script of change all "/" symbols to "-" symbols, which worked very well and i hope someone more gifted can help with my new query.
    Hope i have given enough info and that someone can help
    thanks

    Supplied below is a, quick and dirty (minimal error handling), working self contained (applet) example:
    on run {}
    display dialog "Drag files onto applet for processing."
    end run
    on open (dragged_Items)
    try
    tell application "Microsoft Excel" -- Launch 'Excel' to process '.xls' files
    set tList to {} -- Create an empty list.
    repeat with i in dragged_Items -- Cycle through each dragged '.xls' file.
    open i -- Open each file.
    repeat with j from 1 to 8 -- Cycle through the eight column values of a single row.
    copy (value of cell j of row 3) to end of tList -- Obtain individul cells' value and place into 'tList'.
    end repeat
    end repeat
    repeat until (documents is {}) -- Routine to close all opened '.xls' windows. Here, 'close windows' does not work.
    close windows
    end repeat
    if (not (document 1 exists)) then make new document -- Create a new document, if needed.
    set k to 0 -- Location (position) of a 'tList' item.
    repeat with i from 1 to (count dragged_Items) -- Set row value, of where to ener column values.
    repeat with j from 1 to 8 -- Set cells' column value.
    set k to k + 1 -- Increment 'tList' location.
    set (value of cell j of row i) to (item k of tList) -- Enter value into current rows' columns' cell from 'tList'.
    end repeat
    end repeat
    activate -- Bring window to foreground.
    end tell
    end try
    end open
    Save the AppleScript code as an applet (application).
    Drag the desired files onto the applet for processing.
    The above AppleScript code obtains the cell values of columns A through H of row 3 of each '.xls' file.
    To automatically process the files of a specific folder - utilize the provided code, with respective modifications, within a
    'on adding folder items to this_folder after receiving these_items
    end adding folder items to
    ... AppleScript - 'Folder Action'.

  • Packaging an InDesign document with Placed Illustrator Files which contain PLACED GRAPHICS!

    I've got an InDesign document 215 pages long.  Each page contains a placed Illustrator document... and each Illustrator document contains a placed TIFF.
    When I package the InDesign Document the Illustrator files are gathered into the new location, but InDesign does not gather the TIFFs.  I need to get this material to the book designer, but relinking 215 pages is going to be a very risky and time consuming process--one that will have to be done OVER and OVER again as the project moves from one location to another.  Can anyone recommend a solution?  Why doesn't InDesign look for nested files?
    Does anybody understand what I'm talking about?
    --Jay

    The reason behind link (.psd in layers) means in the future it can be edited.
    If the person receiving to package needs to edit the layers of a PSD placed in an Illustrator file, then yes you would have to manually include the layered PSDs. But if it's just a matter of ensuring full res and color managed output downstream then saving as PDF does that and preserves the links to layered files locally. So if I save as PDF trash a link and reopen the PDF in Illustrator it will look for the link:
    If you save as .ai with the links embedded, the users downstream would be able to unembed and edit a flattened version of the placed art.

  • Placed Excel file - why are the dates wrong?

    I have just relinked a number of Excel spreadsheets in a Mac InDesignCC document and all the dates are now 4 years and a day later than they should be.
    I've searched the forums and it appears that this is related to the Excel 1900/1904 date system but I can't find any solutions.
    The Excel files are from Windows Excel 2010 and look fine in Excel 2011 for Mac and in Apple Numbers.
    So any ideas how can I get InDesign to also show the dates correctly?
    Thanks,
    Graham
    PS asking my client to update all his files to an Apple Mac date system isn't an option!
    PPS I've tried changing the preference in Excel 2011 to "Use 1904 Date System" but that just adds 4 yrs to the dates in the Excel spreadsheets!!

    I have just relinked a number of Excel spreadsheets in a Mac InDesignCC document and all the dates are now 4 years and a day later than they should be.
    I've searched the forums and it appears that this is related to the Excel 1900/1904 date system but I can't find any solutions.
    The Excel files are from Windows Excel 2010 and look fine in Excel 2011 for Mac and in Apple Numbers.
    So any ideas how can I get InDesign to also show the dates correctly?
    Thanks,
    Graham
    PS asking my client to update all his files to an Apple Mac date system isn't an option!
    PPS I've tried changing the preference in Excel 2011 to "Use 1904 Date System" but that just adds 4 yrs to the dates in the Excel spreadsheets!!

  • A script for copying smilar files to a new location

    Hi,
    i newbies to scripting. My challenge is that I want a script to only copy files with names "similar" and not "exactly the same" as the filenames in the text file.
    For example some files have 10 letters file name like "ABC01FGH01.tif".  I have to copy file where starting letter "ABC" and middle letter "FGH" of file name are fixed, but other letters are changed.
    The script sees a file name like "ABC**FGH**.tif", it should search the source location and copy the files having filenames with at least this characters e.g. "ABC02FGH02.tif", "ABC03FGH04.tif" should be copied since it has
    contains "ABC**FGH**.tif".
    Please help.

    Learn how to use wildcards in file names.  '*' is for any number of characters and'?' is for one character.
    COPY ABC??DE???.?x? c:\target
    Start by using DIR
    DIR ABC??DEF???JK.?x?
    ¯\_(ツ)_/¯

  • XSLT Mapping for creating Excel files

    Hi ,
    I am following the blog /people/michal.krawczyk2/blog/2005/12/10/xi-generating-excel-files-without-the-java-nor-the-conversion-agent-not-possible by Michal regarding conversion of Flat files to Excel file format.
    My input xml format is
             <?xml version="1.0" encoding="utf-8"?>
             <FILE>
                  <Record>
         <Name>Navin</Name>
                         <EmpID>123456</EmpID>
                         <Location>Bangalore</Location>
                  </Record>
                 <Record>
         <Name>Ravi</Name>
                         <EmpID>789456</EmpID>
                         <Location>Hyderabad</Location>
                  </Record>
             </FILE>
    i need to convert this file into an Excel format with each record in single rows with Column Header names as Name,EmpID,Location.
    Could you please suggest how the XLST mapping should be done for this as i am very new to XSLT mapping concept.
    Please suggest how we can attain the target structure(datatype) and  steps to do this XSLT mapping.
    Note:- We are not doing Adapter module for this conversion.
    Thanks,
    Navin

    > i need to convert this file into an Excel format with each record in single rows with Column Header names as Name,EmpID,Location.
    This can be done with file content convertion. Use delimiter ; for excel
    > Could you please suggest how the XLST mapping should be done for this as i am very new to XSLT mapping concept.
    If you do not understand XSLT, you you want to maintain your development, in case if an error?
    http://w3schools.com/xsl/default.asp

  • Script for moving & deleting files

    Hi
    I'm quite new to scripts & looking for a script to move selected files with time-stamp & also a script to delete selected file/s in a directory. Below is an example of my requirement
    Move
    Ex:  c:\work\source\test.txt to c:\work\target\test.txt_04202015022100
    Delete
    Ex: c:\work\target\test-1.txt
    Could someone help me please.
    Thank very much
    Neil

    This forum is for scripting questions rather than script requests.
    Please start by reading the following:
    Posting guidelines
    Handy tips for posting to this forum
    How to ask questions in a technical forum
    Rubber duck problem solving
    How to write a bad forum post
    Help Vampires: A Spotter's Guide
    -- Bill Stewart [Bill_Stewart]

  • Formating fonts when placing excel files.

    I need some help. I am creating a catalouge for my business and we use a "proprietary font". We are using an excel spread sheet to link our data to the ID file, as our prices change a couple of times a year and I don't want to keep having to change the cataloge one line at a time. When I place the excel file and change the font and do the set up all is good. It is only when I change a price in the excel file and update the ID (cs5) file that ID changes my font to Times New Roman. Is there a way to have ID keep the font formating so I don't have to change the font everything every time I update the excel file?
    Thanks
    David

    Thanks Bob.. I knew someone would know this. Though I felt silly asking the question in the first place. I do love forums.
    David

  • Looking for Plugins for Powerpoint & Excel files

    I am creating my website in iWeb and it's great! I am looking for a way to have users open the powerpoint and excel files within the website, similar to the way these files open in Internet Explorer. I realize that things are different between ie and Safari; however, I would be most grateful if someone could point me in the right direction. When I put a link to a .pps or .xl file on iWeb, clicking on it opens to the location where the website is stored and then the user can click to open the file. I would like to eliminate having them go to the source of the website.
    I would be most grateful for any help that anyone could provide with this request.
    Respectfully,

    Full list here with links to the sites.....
    http://www.hitsquad.com/smm/mac/

  • Indesign pain when placing vector files

    Hi All,
    I need some help!!
    I'm working on a fairly large catalogue where there is 300+ vector files placed into the Indesign document. As I place more I'm finding Indesign just get slower and slower. GRRRR!!!!! Even when I copy and past an image I have to wait. I'm sick of seeing that bloody beach ball.
    I'm running CS5.
    Am I doing something wrong? Is it just a case of Indesign not being able to handle that many .ai files???
    PLEASE HELP. Because it's doing my head in!
    umit.

    Well I'd stop copy and pasting illustrator into inDesign straight away. That can introduce problems. I'm not a fan of that workflow, others are, but I don't recommend it.
    Placing the files is the preferred method
    ==========================================================
    What version of InDesign are you using?
    If it's CS5 or later go to Preferences> Interface and change the Live Screen Drawing to Delayed
    See if that helps
    ==========================================================
    Also go to View>Display settings and choose "Typical".
    ==========================================================
    File size might be causing slowness issues due to overhead in the indesign file.
    Try doing a File>Save As and save it as a new file name.
    ==========================================================
    If that doesn't fix it then I'd try
    File>Export>InDesign Markup Language (IDML)
    When you open that exported file in INdesign it will open as Untitled
    That might speed up the flow
    ==========================================================

Maybe you are looking for