5 Replies Latest reply: Aug 10, 2012 7:48 PM by Neil Weinberg RSS

    Importing MS docs to odd pages only

    Neil Weinberg Community Member

      About a year ago I got some help from John Hawkinson (thanks again!) with a script to import word documents to multiple pages with the same master page. That discussion can be found here: http://forums.adobe.com/message/3732719#3732719

      I would now like to modify this script to apply it only to the one side of a series of two page spreads using the same master page spread. In other words, let's say I have 300 facing pages that use A-Master. I would like to import 150 pages into the odd (right hand side) pages of the spread (page 1.doc gets imported to page 1, page2.doc gets imported to page 3, page 3.doc gets imported to page 5, etc.).

       

      Is there any easy way to do this?

       

      Thanks,

      Neil

        • 1. Re: Importing MS docs to odd pages only
          [Jongware] CommunityMVP

          Neil Weinberg wrote:

           

          Is there any easy way to do this?

           

          At a glance,

           

          for (i=0; i<p.length; i+=2)
          

           

          ought to work.

           

          [Edit] Gah! There is color, bold, and underlining to mark my change -- but this **** *** forum software does not show it!

           

          The minor change is 'i++' to 'i+=2'. Given some time, I can explain why.)

          • 2. Re: Importing MS docs to odd pages only
            Neil Weinberg Community Member

            Thanks for your help. Would that work, even though the word documents are numbered sequentially (i.e., not odd numbers only)?

             

            In other words page2.doc needs to be imported on page 3 in the INDD file, page3.doc on page 5, page4.doc on page 7, etc.

             

            I think I would need separate counters--one for the word doc numbers and another god the INDD page where it is imported.

             

            Thanks,

            Neil

             

            Envoyé de mon iPhone

            • 3. Re: Importing MS docs to odd pages only
              [Jongware] CommunityMVP

              > I think I would need separate counters--one for the word doc numbers and another god the INDD page where it is imported.

               

              Oui mon frère, I was overseeing the "page number" thingy was re-used in John's script to select a numbered Word file.

               

              Quick-and-ever-so-slightly-dirty: re-use the loop (page) counter but divide it by two! (.. and add 1 because loops run from zero upwards).

               

              frames.textFrames[2].place(new File("/path/to/page"+String((i>>1)+1)+".doc"));

               

              I prefer to use the >> operator here, rather than division, because Javascript is scrupulous about its divisions and dividing an odd number such as '3' by 2 will result in 1.5. Logical, but nasty. Bit shifting the value 3 to the right ibehaves like "divide, round down" -- the lowest bit just gets lost.

               

              Fortunately, you don't have odd numbers in your loop *here* but hey, you might want to repurpose this script for odd numbered pages!

              • 4. Re: Importing MS docs to odd pages only
                Neil Weinberg Community Member

                Thank you sir! That sounds like just the thing. I will give it a try over the weekend and report back to confirm.

                • 5. Re: Importing MS docs to odd pages only
                  Neil Weinberg Community Member

                  Just wanted to report back that this worked like a charm. (I even tried it for the odd-number pages, just like you said. ) Thank you again!

                   

                  If I would not be pushing my luck, I have a follow-up question (sort of a variation on a theme): In addition to the text frames, there are three graphic frames on the left-side page of the spread. How would I modify the script if I wanted to import EPS files into the first graphic frame (i.e., page1.eps, page2.eps, page3.eps...)? In case it is helpful I labeled the first frame as "FrameA" in the Script Label panel.