7 Replies Latest reply on Mar 10, 2010 6:03 AM by a.richter

    place graphic in InDesign document via Excel sheet

    a.richter Level 1

      Hi,

       

      I'm new to scripting in InDesign, but need to work on my skills;)

      In school, I already gathered some basic skills in JavaScript, therefore JavaScript is my choice to write a script for InDesign. Even though the environment is Mac OS X and InDesign CS3, AppleScript might be easier to code in?

       

      Here is the problem:

      An Excel sheet contains a list of names of .eps files generated from SAP. My goal is to create a script that loads the .eps files in this sheet from the location they're saved into the InDesign document and place them in the designated frames.

       

      My first question: Is this even possible?

       

      Currently I'm testing and reading some manuals and refernces, but I would be happy for every tiny bit of hint or help or how to get started, so, thanks a lot for your help in advance!

       

      Greets,

       

       

      Alex

        • 1. Re: place graphic in InDesign document via Excel sheet
          AdobeScripts Level 3

          a.haberl wrote:

           

          An Excel sheet contains a list of names of .eps files generated from SAP. My goal is to create a script that loads the .eps files in this sheet from the location they're saved into the InDesign document and place them in the designated frames.

          I think it would be easier for you if you save/export/whatever your Excel file to TXT document with one-file_name-per-line.

           

          I'm sorry but I'm not JS man. Try to search forum - I think you should find some examples for placing files into INDD file - you will only need to add code for reading data from TXT file.

           

          The basic command is:

           

          app.documents[0].place(path_and_file_name);

           

          This should place path_and_file_name in active document on active page.

           

          robin

          www.adobescripts.com

          • 2. Re: place graphic in InDesign document via Excel sheet
            a.richter Level 1

            Hey robin,

             

            thanks a lot for your quick reply.

            I already stumbled upon the import and placing functions, and think this is the correct way to handle my problem.

            Unfortunately, I forgot to mention that in the file, there are also some short text informationen connected to the graphics, which need to be placed with them as well.

             

            So, my guess is, maybe a xml file would be helpfull?Or is there anything else I should take in consideration?

             

            Greets,

             

             

            .Alex

            • 3. Re: place graphic in InDesign document via Excel sheet
              AdobeScripts Level 3

              a.haberl wrote:

               

              Hey robin,

               

              thanks a lot for your quick reply.

              You are welcome

              I already stumbled upon the import and placing functions, and think this is the correct way to handle my problem.

              Unfortunately, I forgot to mention that in the file, there are also some short text informationen connected to the graphics, which need to be placed with them as well.

               

              So, my guess is, maybe a xml file would be helpfull?Or is there anything else I should take in consideration?

              My idea with TXT file instead of Excel was to give you easier start - you don't need to connect to Excel, etc. - just read TXT file, extract required "fields" - if you have more informations - and do what you need

               

              Or you can play with XML ... but I think script will be quicker way for you

               

              robin

              www.adobescripts.com

              • 4. Re: place graphic in InDesign document via Excel sheet
                Kasyan Servetsky Level 5

                If your layout has a repeating structure, with XML you can do the job even without resorting to scripting.

                For example, let's suppose that every page contains a picture, a caption, etc.

                1. You create structure for the 1st page in ID
                2. Export the sheet as XML file from Excel
                3. Edit XML file in Notepad/an XMLeditor, or best of all transform it on import into ID using XSLT (if you know it, of course)
                4. After importing the XML file, you'll get  the necessary number of pages created and all elements properly placed

                 

                Kasyan

                • 5. Re: place graphic in InDesign document via Excel sheet
                  a.richter Level 1

                  Thank you for your help!

                   

                  After playing around some time, I figured out, it would be easier for me to do an XML Import using a XSLT file.

                  Unfortunately the XML file generated by Excel is very complex, so I have some issues to extract the needed content.

                  Has anybody experience in handling the Microsoft Excel XML?

                   

                  Here is the XML:

                   

                  <Row> 
                  <Cell ss:StyleID="s23"> 
                  <Data ss:Type="String"/> 
                  <NamedCell ss:Name="DATA1"/> 
                  <NamedCell ss:Name="TESTKEYS"/> 
                  <NamedCell ss:Name="TEST0"/> 
                  </Cell> 
                  <Cell ss:StyleID="s23"> 
                  <Data ss:Type="String">4</Data> 
                  <NamedCell ss:Name="DATA2"/> 
                  <NamedCell ss:Name="TESTKEYS"/> 
                  <NamedCell ss:Name="TEST0"/> 
                  </Cell> 
                  <Cell ss:StyleID="s23"> 
                  <Data ss:Type="String">1</Data> 
                  <NamedCell ss:Name="TESTKEYS"/> 
                  <NamedCell ss:Name="DATA3"/> 
                  <NamedCell ss:Name="TEST0"/> 
                  </Cell> 
                  <Cell ss:StyleID="s21"> 
                  <Data ss:Type="String">A63027A01BL</Data> 
                  <NamedCell ss:Name="DATA4"/> 
                  <NamedCell ss:Name="TEST0"/> 
                  </Cell> 
                  </Row> 
                  

                   

                  And this is my XSLT, which just generates the complete content:

                   

                  <?xml version="1.0" encoding="UTF-8"?>
                  <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes" xmlns:err="http://www.w3.org/2005/xqt-errors" xmlns:zuf="http://www.beispiel.com/zuf/3.0" xmlns:pri="http://www.pmn.net/prn/PntI" xmlns:ws="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
                       <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
                        <xsl:template match="Workbook/Worksheet/Table/Row/Cell[NamedCell[@ss:Name='DATA4']]">
                            <Bild>
                                 <xsl:apply-templates select="Data">
                                 </xsl:apply-templates>
                            </Bild>
                       </xsl:template> 
                  
                       <xsl:template match="Workbook/Worksheet/Table/Row/Cell/NamedCell[@ss:Name='DATA4']">
                            <Bild>
                                 <xsl:value-of select="Workbook/Worksheet/Table/Row/Cell[NamedCell[@ss:Name='DATA4']]/text()">
                                 </xsl:value-of>
                            </Bild>
                       </xsl:template>
                  </xsl:stylesheet>
                  
                  
                  • 6. Re: place graphic in InDesign document via Excel sheet
                    Kasyan Servetsky Level 5

                    I did it in a different way — here is an example*:

                     

                    Spreadsheet in Excel

                    excel.png

                     

                    Exported XML file

                     

                    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
                    <dataroot>
                         <employees>
                              <Employeeid>1</Employeeid>
                              <Efirstname>James</Efirstname>
                              <Elastname>James</Elastname>
                              <Etitle>President</Etitle>
                              <Ephone>847-555-1110</Ephone>
                              <Eemail>jjames@cookingwithxml.com</Eemail>
                         </employees>
                         <employees>
                              <Employeeid>2</Employeeid>
                              <Efirstname>Bill</Efirstname>
                              <Elastname>Williams</Elastname>
                              <Etitle>Vice-president</Etitle>
                              <Ephone>847-555-1111</Ephone>
                              <Eemail>bwilliams@cookingwithxml.com</Eemail>
                         </employees>
                    </dataroot>
                    

                     

                    ------------------------------

                    * Designers Guide to Adobe InDesign and XML

                    • 7. Re: place graphic in InDesign document via Excel sheet
                      a.richter Level 1

                      Ok, this looks nice.

                      But how did you do that? I can only export to XML in Excel, without any formatting options.