3 Replies Latest reply on Jun 11, 2009 7:07 AM by Dave Saunders

    not working in CS3


      This code is working in Cs2 but not working in cs3 could any one tell me the code for CS3.








      function FigureWithoutCaption(ImgPath)   
      app.findTextPreferences = app.changeTextPreferences = null
      var mycount_1=0;
      var start="<Insert ";
      var CloseTag=">"
      //var srch_cont=app.activeDocument.search(start,false,false,undefined,undefined,undefined);
      alert("Finding the image file(EPS)")
      var srch_cont=app.activeDocument.search(start,false,false,undefined,undefined,undefined);

          var Cnt=srch_cont[i].paragraphs[0].contents;
      var ImgNam=FindFileName(Cnt,start);


              //    var len=srch_cont[i].paragraphs[0].search(start+ImgNam+CloseTag,false,false,undefined,undefin ed,undefined);
              var len=srch_cont[i].paragraphs[0].search(start+ImgNam+CloseTag,false,false,undefined,undefin ed,undefined);
                      var myfile=File(ImgPath+"/"+ImgNam);
                          myerrorlist=myerrorlist+"\nFigure Without Caption: "+"'"+ImgNam+"'"+" not found in the ImageFolder";
      return mycount_1



        • 1. Re: not working in CS3
          Thomas B. Nielsen Level 3

          You can make it work by putting it in another scriptfolder, try searching the forum.


          To make it CS3 code:

          For a start, have a look at the search examples in CS3 - you no longer search the same way as in CS2.


          The Find Text example from CS3:

          //An InDesign CS3 JavaScript
          //Shows how to find text.
          //Clear the find/change preferences.
          app.findTextPreferences = NothingEnum.nothing;
          app.changeTextPreferences = NothingEnum.nothing;
          //Search the document for the string "Text".
          app.findTextPreferences.findWhat = "text";
          //Set the find options.
          app.findChangeTextOptions.caseSensitive = false;
          app.findChangeTextOptions.includeFootnotes = false;
          app.findChangeTextOptions.includeHiddenLayers = false;
          app.findChangeTextOptions.includeLockedLayersForFind = false;
          app.findChangeTextOptions.includeLockedStoriesForFind = false;
          app.findChangeTextOptions.includeMasterPages = false;
          app.findChangeTextOptions.wholeWord = false;
          var myFoundItems = app.documents.item(0).findText();
          alert("Found " + myFoundItems.length + " instances of the search string.");
          function myCreateExampleDocument(){
              //Create an example document.
              var myDocument = app.documents.add();
              //Create a text frame on page 1.
              var myTextFrame = myDocument.pages.item(0).textFrames.add();
              //Set the bounds of the text frame.
              myTextFrame.geometricBounds = myGetBounds(myDocument, myDocument.pages.item(0));
              //Fill the text frame with placeholder text.
              var myString = "This is some text. This is some more text. This is even more example text.\rThis is text in another paragraph.";
              myTextFrame.contents = myString;
          function myGetBounds(myDocument, myPage){
              var myPageWidth = myDocument.documentPreferences.pageWidth;
              var myPageHeight = myDocument.documentPreferences.pageHeight
              if(myPage.side == PageSideOptions.leftHand){
                  var myX2 = myPage.marginPreferences.left;
                  var myX1 = myPage.marginPreferences.right;
                  var myX1 = myPage.marginPreferences.left;
                  var myX2 = myPage.marginPreferences.right;
              var myY1 = myPage.marginPreferences.top;
              var myX2 = myPageWidth - myX2;
              var myY2 = myPageHeight - myPage.marginPreferences.bottom;
              return [myY1, myX1, myY2, myX2];

          1 person found this helpful
          • 2. Re: not working in CS3
            RockScript Level 1

            Thanks Thomas

            • 3. Re: not working in CS3
              Dave Saunders Level 4

              But CS2 doesn't support findTextPreferences, so while your script might work in CS2 as written here, it is not properly clearing the preferences first.


              What you should do is search this forum on the word "findText". That will deliver many examples of how to do searches in CS3/CS4.