How do I create a series of text frames using values from Excel list?

First of all, this is the very first script I'm attempting to write from scratch. I'm completely green at scripting, and I've picked up a few snippets from Adobe's ID scripting guide, but nothing has really stuck yet relating to this particular objective.
My supervisor keeps a master list of ad spaces, with the name of the account, how wide the space is, and how tall the space is, all in an Excel sheet. These spaces can number in the hundreds, and I am stuck manually drawing one rectangle for every space, which takes a very long time.
I'd like to create/have help creating a script that will take these values and "automagically" draw these spaces in the form of text frames, with the width (in columns) and the height (in inches) defined by the values in the master list, as well as the name of each account appearing in the subsequent text frames.
The script doesn't necessarily need to be able to pull the values straight from the Excel sheet; I can transfer the values to a support text file if needed, or directly into the script, changing it as I need it. A big thing (if it is not able to pull right from an Excel sheet) is that the number of spaces changes weekly, and so do the accounts, and the width and the height. Accordingly, it would be ideal if the values from the sheet could be changed easily, so as to create a new set of spaces as needed.
Positioning for each space is not crucial, only height and width. If they all appear on top of each other on the same page, that will be a result for me. The main idea is to not have to draw them all manually, one by one.
To me, this sounds like a tall order, but hopefully some experienced scripters out there can assist me, as I wish to become experienced as well.
So, the TL;DR version:
- Script needs to draw a series of text frames.
- Text frames dimensions need to be defined by width and height values from Excel sheet.
- Text frames must have account name as contents (from account names in Excel sheet).
- Accounts, width and height change every week in the Excel sheet, so must be relatively easy to exchange all of the values.
- The width values are on the Excel sheet as columns. It would be ideal if the script could convert those numbers into multiples of columns as needed.
- (Optional) Script can pull values directly from Excel sheet.
- (Optional) Script can define text frame fill color as gray. (If it works as I think it will, I could just select all the resulting text frames myself and set them all to gray at once... I'm not that lazy )
Thanks in advance to whomever can assist in any possible way, even if it is just a push in the right direction. This script will save 1-2 hours of tedium every week.

Sound like the perfect thing for InDesign Scripting.
I would copy the Excel contents into a text file, to get a format that is easily read from InDesign, and there will automatically be a TAB for each "cell" just using copy/paste.
Here is a piece of code, that you perhaps could go on with (adding variable to change pages and location on page, and other stuff).
The readFileLineByLine function, can be easily re-used with any function using "callback". You simply supply the function to it, that you want to be executed for every line of text that is read:
const COLUMN_WIDTH = 2; // Define the column width in inch
var pageIndex;
var textFramesExported; // not implemented.
// Add a new dokument. Set myDoc to app.activeDocument to use
// the current document instead of creating a new one.
var myDoc = app.documents.add();
// The doSomethingWithTextRow function is called upon for every line of text read.
readFileLineByLine('c:\\test.txt', doSomethingWithTextRow);
function doSomethingWithTextRow(row){
    // We expect the text line to be TAB separated (\t = TAB). We get that from just copying the contents of an
    // excel file into a text document.
    var cells = row.split('\t');
    var companyName = cells[0]; // The Company name in the first slot of the array
    var width = COLUMN_WIDTH * cells[1];
    var height = cells[2];
    // Create a new text frame for every row handled
    if (pageIndex==undefined) pageIndex = 0; // Count up when you have exported a number of texts, I leave this for you to do.
    var newTextFrame = myDoc.pages[pageIndex].textFrames.add();
    newTextFrame.contents = companyName;
    // The text frame is created in the top left corner.
    newTextFrame.geometricBounds = [0, 0, height + ' in', width + ' in']; // Top, Left, Bottom, Right
    // You might want to move the textframes to other positions, keeping track of how many you put out per page.
    newTextFrame.move( [10, 10] );
function readFileLineByLine(path, callbackFn){
    var myFileIn = new File(path);
    if (File.fs == 'Windows'){
        // This was probably added to recognize UTF-8 (even without its start marker?)
        myFileIn.encoding = 'UTF-8';
    myFileIn.open('r');
    var myEncoding = myFileIn.encoding;
    try{
        if (!myFileIn.exists){
            throw('Missing file: ' + myFileIn.fsName)
        var ln = '';
        while(!myFileIn.eof){
            // Read the lines from the file, until an empty line is found [now as a remark].
            ln = myFileIn.readln()
            // if(ln !='' && ln!='\n'){
               // Call the function supplied as argument
               callbackFn(ln);
    }catch(e){
        alert(e);
        gCancel = true;
    finally{
        myFileIn.close();
The file in C:\ in my example was saved as UTF-8 and looks like this (showing hidden characters):
Message was edited by: Andreas Jansson

Similar Messages

  • How do I create a series of text frames from a list of files?

    And I'm back again.
    This time, I'm wondering how I can use JavaScript to place a series of text frames from a list of files, preferably with the ability to specify criteria before running the script.
    Here's the details: I work for a newspaper and I lay out stories for the pages (in addition to the other part of my job, laying out ad spaces, as detailed in a previous thread, for which I requested another script, thanks Andreas and Jongware ). The file names for the stories are labeled for the section they go in, like L- for Life, C- for Comment, S- for Sports, etc.
    I'd like to create a script that asks for a criteria in a text box (where I can type L-, C-, S- or whatever else I need) and then places all of the stories, in a specified directory, whose file names match what was typed in the box, one text frame for each.
    I can't rightly tell if this is a simpler or more difficult script to write out, but I plan on putting research into it as usual so I can develop it myself. However, I figured it would be more efficient to ask first, then research, so that while I'm researching, I can refer to the opinions of my fellow forumites, and/or the mods.
    Thanks again for any assistance offered.

    And I'm back again.
    This time, I'm wondering how I can use JavaScript to place a series of text frames from a list of files, preferably with the ability to specify criteria before running the script.
    Here's the details: I work for a newspaper and I lay out stories for the pages (in addition to the other part of my job, laying out ad spaces, as detailed in a previous thread, for which I requested another script, thanks Andreas and Jongware ). The file names for the stories are labeled for the section they go in, like L- for Life, C- for Comment, S- for Sports, etc.
    I'd like to create a script that asks for a criteria in a text box (where I can type L-, C-, S- or whatever else I need) and then places all of the stories, in a specified directory, whose file names match what was typed in the box, one text frame for each.
    I can't rightly tell if this is a simpler or more difficult script to write out, but I plan on putting research into it as usual so I can develop it myself. However, I figured it would be more efficient to ask first, then research, so that while I'm researching, I can refer to the opinions of my fellow forumites, and/or the mods.
    Thanks again for any assistance offered.

  • How do I create columns in my text when using pages?

    How do I create columns in my text when using pages?

    Presuming you are using Pages 5.2.2:
    select the text > choose the number of columns in the Format > Layout sidebar
    Peter

  • How to create the temp table in Sybase with values from Excel ?

    Dear Sir/Madam,
    I know this is not related with oracle DB, however i am in the need of help from you people who worked on Sybase. plz help me..
    I have the excel sheet which contains EmpId and EmpName values. I just wanted to read these two values one by one from an excel sheet and loaded them into one temp table in Sybase. is it possible thru sqlldr ?
    here is the sample code for your reference:
    begin tran
    create table tempdb..empIdName (emp_id int identity,emp_name varchar(50))
    go
    Awaiting for your valuable reply
    thanks
    pannar

    there is some hint provided by sybase user
    If it's Sybase IQ, you can export the excel file to a CSV file, then use a LOAD TABLE statement to get the data into your temporary table.
    For ASE, BCP would provide similar functionality.
    I am using ISQLW tool to work with sybase DB. what query to load the excel data to tem table in sybase. anyone who knows this? help me

  • How to create a muli line text area using JavaFx

    Hi all,
    Since the preview SDK does not contain TextArea any more, I am wondering how to create a muli line text area using JavaFX. The behaviour of this text area/field should be somehow similar to JTextArea in Swing or StyledTextWidget in SWT.
    Does JavaFX have any support for this? What would be a sensible approach to create such a widget?
    Thanks for your suggestions,
    br michael

    This is a pretty old thread (I know I came across this while searching for something similar recently), but I figured I'd throw this out there in case other people might find this useful. As I write this, JavaFX's latest version is 1.3... which may have added the needed functionality since the last post.
    You can now create a multi-line text area using a TextBox and by specifying the nubmer of lines and setting the "multiline" value to true. It may not offer all of the same functionality as JTextArea, but it did the job for what I needed... newlines by pressing enter, scrollbar if text surpasses height, etc.
    Here's a simple example:
    Group {
       content: [
          TextBox {
             text: "This is a multi-line textbox"
             lines: 10  // <-- this may/may not be necessary depending on your situation. Default is 5.
             multiline: true
    }Edited by: loeschg on Jul 29, 2010 2:59 PM

  • How do I create an outline around text please

    hi all, How do I create an outline around text please
    thanks,

    You can see here that you can simply apply a stroke to live text by double clicking the stroke icon in the bottom left of the toolbar and selecting a color. I chose red.
    If you select the text, then go to Type > Create Outlines, you get more options in the stroke palette, like whether the stroke is aligned to the outside or inside of the text object's boundary. The text below is outlined with the stroke aligned to the outside.

  • How do you create a border around text?

    how do you create a border around text?

    Can you be a little more specific about what you are trying to do and the application that you want to use? The methods can vary depending on the application and who published it. For instance, if you're using Final Cut Pro here is a discussion describing how the border can be created.
    https://discussions.apple.com/thread/1470384?start=15&tstart=0
    If you are using an Apple branded application you can also post in the specific forums for those applications in order to help ensure a complete response.
    https://discussions.apple.com/community/ilife
    https://discussions.apple.com/community/iwork
    https://discussions.apple.com/community/professional_applications

  • How t o create breadcrumbs in flash cs 5 using action script 2.0?

    how t o create breadcrumbs in flash cs 5 using action script 2.0?
    If the user is going throungh some buttons then at last there is breadcrumb on last scene (like it is selected 1,2 or 3 button etc..)then final display should show last used button.
    Am besically looking for breadcrumb.Can anyone know how to create breadcrumb with using movie clip?or any other code?
    Can any one help me?

    My problem is when i cross first,second and then third scene then on third scene if there is any crieteria like to show the value which user have used like if user have selected "a" on first scene and "b" on second scene.then on third scene if there is criteria-
    first scene-
    second scene-
    then it should show value like-
    first scene-"a"
    second scene-"b"
    This "a","b", have separet sound file.It should show "a","b" text and also sound should play after click on button.
    Can any on help?

  • How to get the value from select list to text box

    Hi,
    I have a select list i want to retrieve the value from select list to text box.
    How can i do that???
    Regards,
    Sakthi.

    Hi Sakthi,
    Yo can use the Java script for that..
    Dynamically the value will come into text box.
    Use the below script.
    <script type="text/javascript">
    function disFormItems()
    var lReturn = $v(here your select list name)
    alert(lReturn);
    document.getElementById(here your text box name).value =lReturn; }
    </script>Cheers,
    Shan

  • How can i create a new and tableless database using database configuration

    How can i create a new and tableless database using database configuration

    How can i create a new and tableless database using database configuration
    Just don't install the sample schemas. See the installation guide
    http://docs.oracle.com/cd/E11882_01/server.112/e10831/installation.htm
    Using the Database Configuration Assistant
    When you install Oracle Database with the Oracle Universal Installer, the sample schemas are installed by default if you select the Basic Installation option. Selecting the sample schemas option installs all five schemas (HR, OE, PM, IX, and SH) in the database. If you choose not to install the sample schemas at that time, you can add them later by following the instructions in section "Manually Installing Sample Schemas".
    Choose a custom install and don't install the sample schemas.
    All other schems/tables installed are REQUIRED by Oracle

  • How to Create a OLAP Cube in DEV using SSAS from Raw file system backup from Production?

    How to Create a OLAP Cube in DEV using SSAS from Raw file system backup from Production? I dont have a .abf file available. Two paritions in production are missing data. We were able to get back file system backup which contains the files for these two paritions.
    How do I create a cube in Dev using this file system backup.
    we are on SQL Server 2008R2.
    Thanks,

    How to Create a OLAP Cube in DEV using SSAS from Raw file system backup from Production? I dont have a .abf file available. Two paritions in production are missing data. We were able to get back file system backup which contains the files for these two paritions.
    How do I create a cube in Dev using this file system backup.
    we are on SQL Server 2008R2.
    Thanks,

  • I would like to know how i can create a bell graph with out using sub VIs, the data that i created consists in 500 readings with values of 0 to 100, i calculated the mean value and standard diviation. I hope some one can help me

    I would like to know how i can create a bell graph with out using sub VIs, the data that i created consists in 500 readings with values of 0 to 100, i calculated the mean value and standard diviation. I hope some one can help me

    Here's a quick example I threw together that generates a sort-of-bell-curve shaped data distribution, then performs the binning and plotting.
    -Kevin P.
    Message Edited by Kevin Price on 12-01-2006 02:42 PM
    Attachments:
    Binning example.vi ‏51 KB
    Binning example.png ‏12 KB

  • I have all my pictures in an external drive, how do i create a library in iphoto without using my internal drive space?

    i have all my pictures in an external drive (around 1tb), how do i create a library in iphoto without using my internal drive space? thanks!

    In iPhoto use the command "File > Switch to Library" and then click "Create New" in the Library Chooser panel.
    Select a folder on your external drive as the destination.
    You can also get to this panel by holding down the alt/options key when you launch iPhoto.

  • How can i create an indicator to read the RMS value of my FFT using FFT Spectrum (Mag-Phase).vi

    Hai to all,
    how can i create an indicator to read the RMS value of my FFT using FFT Spectrum (Mag-Phase).vi.
    as u can see in my block diagram(attached), i can use statistic to read the RMS value for the data but i cant's use it on the FFT Spectrum (mag-Phase).vi .
    Thank you for helping.
    Attachments:
    block diagram.jpg ‏48 KB

    hafizzuddin wrote:
    thank you for the opinions, for now i am not using any express Vi..
    In the long run you will benefit from this. Anyway is your problem solved, or do you need more help?
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)

  • Each time I create a new album in IPhoto, photos from another album or from photo stream are automatically dumped into the new album..  how do I create a blank album and then import photos from a flash drive into the new album?

    each time I create a new album in IPhoto, photos from another album or from photo stream are automatically dumped into the new album..  how do I create a blank album and then import photos from a flash drive into the new album?

    just import the iPhoto
    Surely you meant "just import the photo"?  The Spell checker is dangerously creative !

Maybe you are looking for

  • Unable to activate Genius

    I am unable to activate Genius since upgrading to Windows 7. Prior with Vista and iTunes 9 Genius worked fine. Upgrade to Win7 and I cannot activate Genius. It goes through step 1 fine then goes into step 2. It pops up an error message after about a

  • Cannot Restore My BACK UP data to my Q5 !! PLEASE HELP!!!!

    im in the middle of a huge problem where i have become desperate and lost, here is how it all began, first of all i received an alert that a new update is available for my Q5 which is 10.2.1537 when i started to downloanding it i received an error th

  • Commonwealth games TimeZone problems in 1.4.2

    Hi all, I am after a patch for Java 1.4.2 (currently using 1.4.2_05). for the commonwealth games timezone change. The following bug as already be marked as fixed in 1.4.2_11(b01) http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6332148 I cannot fin

  • Server not found (sorry, I'm a total novice)

    I'm sorry for my complete ignorance, but I was hoping someone could help me with a problem I'm having. I just installed Web Server 7, started the Administration Server, and entered the address to the Administration Console, but the server cannot be f

  • Photoshop CS5 fails to open pdfs

    Photoshop CS5 fails to open some pdfs created in Indesign. The message 'Could not complete your request because of a program error' comes up. Is this posibly a system issue not seeing the file information or a fault in photoshop.