2 Replies Latest reply on Mar 26, 2009 8:42 AM by (Marcin_Ruszala)

    Help imposition JSX -> VB

      hi,
      how this script remake to vb language ??

      f (app.documents.length != 0) {
      result = buildBooklet(app.documents[0]);
      if (result != null) {
      alert(result);
      }
      }

      function buildBooklet() {

      var myPages = app.documents[0].pages;
      if (myPages.length % 4 != 0) {
      return("Document length isn't a multiple of four.");
      }

      if (app.documents[0].modified) {
      if (confirm("Document has unsaved changes. Click OK to save them and proceed.")){
      app.documents[0].save(app.documents[0].fullName);
      } else {
      return null;
      }
      }



      if (app.version == 3) {
      app.userInteractionLevel = UserInteractionLevels.neverInteract;
      } else {
      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
      }

      var myFN = app.documents[0].fullName;
      var myName = app.documents[0].name;
      var n = 0;
      var myTN = app.documents[0].filePath + "/" + myName.split(".indd")[0] + n + ".indt";
      while (File(myTN).exists) {
      n++;
      myTN = app.documents[0].filePath + "/" + myName.split(".indd")[0] + n+ ".indt";
      }
      app.documents[0].save(File(myTN),true);
      app.documents[0].close();
      app.open(File(myTN));
      File(myTN).remove();

      if (app.version == 3) {
      app.userInteractionLevel = UserInteractionLevels.interactWithAll;
      } else {
      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
      }

      app.documents[0].documentPreferences.allowPageShuffle = false;

      for (i=0; myPages.length > i; i++) {
      var origSection = myPages[i].appliedSection;
      var origNumbering = origSection.pageNumberStyle;
      origSection.pageNumberStyle = PageNumberStyle.arabic;
      var pageName = myPages[i].name;
      var sectName = origSection.name;
      if (sectName != "") {

      var testPageName = pageName.split(sectName)[1];
      if (testPageName != null) {
      pageName = testPageName;
      }
      }
      var pageNo = Number(pageName);

      if (app.version == 3){
      newSection = app.documents[0].sections.add(undefined, undefined, {
      pageStart:app.documents[0].pages[i],
      continueNumbering:false,
      pageNumberStart:pageNo,
      pageNumberStyle:origNumbering,
      marker: origSection.marker,
      name: origSection.name
      });
      origSection.pageNumberStyle = origNumbering;
      } else {
      newSection = app.documents[0].sections.add({
      pageStart:app.documents[0].pages[i],
      continueNumbering:false,
      pageNumberStart:pageNo,
      pageNumberStyle:origNumbering,
      marker: origSection.marker,
      name: origSection.name
      });
      origSection.pageNumberStyle = origNumbering;
      }
      }
      app.documents[0].documentPreferences.allowPageShuffle = true;

      for (i=0; (myPages.length/2)>i; i++){
      if (i % 2 == 0) {
      app.documents[0].pages[myPages.length - 1].move(LocationOptions.before,app.documents[0].pages[i*2],BindingOptions.leftAlign);
      } else {
      app.documents[0].pages[myPages.length - 1].move(LocationOptions.after,app.documents[0].pages[i*2],BindingOptions.rightAlign);
      }
      }



      app.activeDocument.textPreferences.zOrderTextWrap = !app.activeDocument.textPreferences.zOrderTextWrap;
      app.activeDocument.textPreferences.zOrderTextWrap = !app.activeDocument.textPreferences.zOrderTextWrap;
      }

      thx ;)