5 Replies Latest reply on Mar 19, 2014 12:26 PM by Jump_Over

    Issue with script after upgrade - "HarbsTestMenu"

    kenzierlemmons Level 1

      Hi,

       

      We upgraded our InDesign from CS4 to CS6 awhile ago, and I've just found a script that we've made no long works properly.

       

      It was authored by a former employee, and I'm not terribly versed with scripting myself, so I wanted to see if you guys could help me out.

       

      Here are his instructions:

       

        • For any errors or problems you may encounter using the sublimation menu, the script is located in C:\Program Files (x86)\Adobe\Adobe InDesign CS4\Scripts\XHTML For Digital Editions\startup scripts\SublimationMenu.jsx.
        • The sublimation menu requires that the PlaceHolder_.ai files are located in C:\Program Files (x86)\Adobe\Adobe InDesign CS4\Scripts\XHTML For Digital Editions. Without these files the menu will not be able to add new pages correctly.
        • If any problems somehow arise with the menu installed on your computer you can find a back up with all of the necessary files located in the Print Templates > Master Files > Scripts folder
        • To remove the sublimation menu remove the script from the startup scripts folder on your computer. Then open InDesign and press CTRL+ALT+SHIFT immediately, if performed correctly a pop up should appear asking if you'd like to delete InDesign Preference files, click yes.

       

      The folder "XHTML For Digital Editions" does not exist for the new install of CS6. I placed the file in SublimationMenu.jsx file in \Adobe InDesign CS6\Scripts\startup scripts\ and the (8) different PlaceHolder_.ai files in \Adobe InDesign CS6\Scripts\

       

      However, when I used the menu to add new pages it gives me the following error:

       

      error_message.jpg

       

      I'm not sure why it is looking in the Documents folder rather than in one of the many the Adobe folders.

       

      Here is the content of the script:

       

      #targetengine "HarbsTestMenu"

       

      menuInstaller();

       

      function menuInstaller() {

          // SET THE FILES THAT ARE TRIGGERED BY MENU ITEMS

          menuItem1Handler = function( /*onInvoke*/ ){

       

      var myDocument = app.activeDocument;

      var myPage = myDocument.pages.item(-1);

      app.activeDocument.pages.add();

      app.activeDocument.activeLayer=app.activeDocument.layers.itemByName("PRINT");

      myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;

      myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;

      '~';

       

      if(app.activeDocument.metadataPreferences.documentTitle == 'Coffee Mugs NoWrap'){

      var myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 3.8125, 8.0625]});

       

      myRectangle.place(File('PlaceHolderMug.ai'));

      myRectangle.resize(CoordinateSpaces.INNER_COORDINATES,AnchorPoint.RIGHT_CENTER_ANCHOR,Resi zeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,[290.25, 274.5]);

      myRectangle.move([9.8438, 0]);

      myRectangle.locked ^= 1;

       

      myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 3.8125, 8.0625]});

      myRectangle.place(File('PlaceHolderMug.ai'));

      myRectangle.resize(CoordinateSpaces.INNER_COORDINATES,AnchorPoint.RIGHT_CENTER_ANCHOR,Resi zeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,[290.25, 274.5]);

      myRectangle.move([4.9774, 0]);

      myRectangle.locked ^= 1;

       

      myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 3.8125, 8.0625]});

      myRectangle.place(File('PlaceHolderMug.ai'));

      myRectangle.resize(CoordinateSpaces.INNER_COORDINATES,AnchorPoint.RIGHT_CENTER_ANCHOR,Resi zeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,[290.25, 274.5]);

      myRectangle.move([0.1181, 0]);

      myRectangle.locked ^= 1;

       

      myRectangle = myPage.rectangles.add({rotationAngle:180, strokeWeight:0, geometricBounds:[0, 0, 3.8125, 8.0625]});

      myRectangle.place(File('PlaceHolderMug.ai'));

      myRectangle.resize(CoordinateSpaces.INNER_COORDINATES,AnchorPoint.RIGHT_CENTER_ANCHOR,Resi zeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,[290.25, 274.5]);

      myRectangle.move([4.1493, 8.5]);

      myRectangle.locked ^= 1;

       

      myRectangle = myPage.rectangles.add({rotationAngle:180, strokeWeight:0, geometricBounds:[0, 0, 3.8125, 8.0625]});

      myRectangle.place(File('PlaceHolderMug.ai'));

      myRectangle.resize(CoordinateSpaces.INNER_COORDINATES,AnchorPoint.RIGHT_CENTER_ANCHOR,Resi zeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,[290.25, 274.5]);

      myRectangle.move([9.0226, 8.5]);

      myRectangle.locked ^= 1;

       

      myRectangle = myPage.rectangles.add({rotationAngle:180, strokeWeight:0, geometricBounds:[0, 0, 3.8125, 8.0625]});

      myRectangle.place(File('PlaceHolderMug.ai'));

      myRectangle.resize(CoordinateSpaces.INNER_COORDINATES,AnchorPoint.RIGHT_CENTER_ANCHOR,Resi zeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,[290.25, 274.5]);

      myRectangle.move([13.8681, 8.5]);

      myRectangle.locked ^= 1;

      }

       

      if(app.activeDocument.metadataPreferences.documentTitle == '4in Clocks'){

      var myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 4.125, 4.125]});

      myRectangle.place(File('PlaceHolder4inClock.ai'));

      myRectangle.move([0.2222, 0.3472]);

      myRectangle.locked ^= 1;

       

      myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 4.125, 4.125]});

      myRectangle.place(File('PlaceHolder4inClock.ai'));

      myRectangle.move([6.6597, 0.3472]);

      myRectangle.locked ^= 1;

       

      myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 2.25, 8.25]});

      myRectangle.place(File('PlaceHolderPlaque8.ai'));

      myRectangle.move([1.375, 5.8611]);

      myRectangle.locked ^= 1;

      }

       

      if(app.activeDocument.metadataPreferences.documentTitle == '5x7 Signs'){

          var myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 7.0625, 5.0625]});

          myRectangle.place(File('PlaceHolder5x7Sign.ai'));

          myRectangle.move([0.2535, 0.7852]);

          myRectangle.locked ^= 1;

       

          myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 7.0625, 5.0625]});

          myRectangle.place(File('PlaceHolder5x7Sign.ai'));

          myRectangle.move([5.7181, 0.7852]);

          myRectangle.locked ^= 1;

          }

       

      if(app.activeDocument.metadataPreferences.documentTitle == '8in Clocks'){

          var myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 8.1389, 8.1389]});

          myRectangle.place(File('PlaceHolder8inClock.ai'));

          myRectangle.move([0.1875, 1.4375]);

          myRectangle.locked ^= 1;

          }

       

      if(app.activeDocument.metadataPreferences.documentTitle == 'Plaques'){

          var myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 2.25, 8.25]});

      myRectangle.place(File('PlaceHolderPlaque8.ai'));

      myRectangle.move([1.375, 0.3958]);

      myRectangle.locked ^= 1;

       

      myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 2.25, 8.25]});

      myRectangle.place(File('PlaceHolderPlaque8.ai'));

      myRectangle.move([1.375, 3.1181]);

      myRectangle.locked ^= 1;

       

      myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 2.25, 8.25]});

      myRectangle.place(File('PlaceHolderPlaque8.ai'));

      myRectangle.move([1.375, 5.8611]);

      myRectangle.locked ^= 1;

      }

       

      if(app.activeDocument.metadataPreferences.documentTitle == '8x12 Signs'){

          var myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 8.15, 12.15]});

      myRectangle.place(File('PlaceHolder8x12Sign.ai'));

      myRectangle.move([0.925, 0.175]);

      myRectangle.locked ^= 1;

          }

       

      if(app.activeDocument.metadataPreferences.documentTitle == 'Beer Steins'){

          var myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 3, 3.75]});

      myRectangle.place(File('PlaceHolderBeerStein.ai'));

      myRectangle.rotationAngle = -90;

      myRectangle.move([3.5208, 0.1319]);

      myRectangle.locked ^= 1;

       

      myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 3, 3.75]});

      myRectangle.place(File('PlaceHolderBeerStein.ai'));

      myRectangle.rotationAngle = -90;

      myRectangle.move([7.1979, 0.1319]);

      myRectangle.locked ^= 1;

       

      myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 3, 3.75]});

      myRectangle.place(File('PlaceHolderBeerStein.ai'));

      myRectangle.rotationAngle = -90;

      myRectangle.move([10.875, 0.1319]);

      myRectangle.locked ^= 1;

       

      myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 3, 3.75]});

      myRectangle.place(File('PlaceHolderBeerStein.ai'));

      myRectangle.rotationAngle = -90;

      myRectangle.move([3.5208, 4.625]);

      myRectangle.locked ^= 1;

       

      myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 3, 3.75]});

      myRectangle.place(File('PlaceHolderBeerStein.ai'));

      myRectangle.rotationAngle = -90;

      myRectangle.move([7.1979, 4.625]);

      myRectangle.locked ^= 1;

       

      myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 3, 3.75]});

      myRectangle.place(File('PlaceHolderBeerStein.ai'));

      myRectangle.rotationAngle = -90;

      myRectangle.move([10.875, 4.625]);

      myRectangle.locked ^= 1;

          }

       

      if(app.activeDocument.metadataPreferences.documentTitle == 'Can Coolers'){

          var myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 8.5, 11]});

      myRectangle.place(File('PlaceHolderCanCooler.ai'));

      myRectangle.locked ^= 1;

          }

       

      if(app.activeDocument.metadataPreferences.documentTitle == 'Coffee Mugs Wrap'){

      var myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 3.8125, 8.0625]});

      myRectangle.place(File('PlaceHolderMug.ai'));

      myRectangle.move([0.125, 0]);

      myRectangle.locked ^= 1;

       

      myRectangle = myPage.rectangles.add({strokeWeight:0, geometricBounds:[0, 0, 3.8125, 8.0625]});

      myRectangle.place(File('PlaceHolderMug.ai'));

      myRectangle.resize(CoordinateSpaces.INNER_COORDINATES,AnchorPoint.RIGHT_CENTER_ANCHOR,Resi zeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,[290.25, 274.5]);

      myRectangle.move([9.8438, 0]);

      myRectangle.locked ^= 1;

       

      myRectangle = myPage.rectangles.add({rotationAngle:180, strokeWeight:0, geometricBounds:[0, 0, 3.8125, 8.0625]});

      myRectangle.place(File('PlaceHolderMug.ai'));

      myRectangle.move([8.1875, 8.5]);

      myRectangle.locked ^= 1;

       

      myRectangle = myPage.rectangles.add({rotationAngle:180, strokeWeight:0, geometricBounds:[0, 0, 3.8125, 8.0625]});

      myRectangle.place(File('PlaceHolderMug.ai'));

      myRectangle.resize(CoordinateSpaces.INNER_COORDINATES,AnchorPoint.RIGHT_CENTER_ANCHOR,Resi zeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,[290.25, 274.5]);

      myRectangle.move([13.875, 8.5]);

      myRectangle.locked ^= 1;

      }

       

       

       

              }

       

       

       

       

       

          menuItem2Handler = function( /*onInvoke*/ ){

             //LabelGraphics.jsx

      //An InDesign CS4 JavaScript

      /* 

      @@@BUILDINFO@@@ "LabelGraphics.jsx" 2.0.0 10-January-2008

      */

      //Adds labels to the graphics in the active document.

      //

      //For more on InDesign scripting, go to http://www.adobe.com/products/indesign/scripting/index.html

      //or visit the InDesign Scripting User to User forum at http://www.adobeforums.com

      //

      main();

      function main(){

          //Make certain that user interaction (display of dialogs, etc.) is turned on.

          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

          if(app.documents.length != 0){

              if(app.documents.item(0).allGraphics.length != 0){

                      myAddLabels();

              }

              else{

                  alert("Document contains no graphics.");

              }

          }

          else{

              alert("Please open a document and try again.");

          }

      }

       

       

      function myAddLabels(myLabelHeight, myLabelOffset){

          var myDocument = app.documents.item(0);

          var myGraphics = myDocument.allGraphics;

          var myLabelStyle;

          var layers = app.activeDocument.layers.everyItem().getElements();

          for(var i=layers.length-1;i>=0;i--){

              if(app.activeDocument.layers[i].name == "labels"){

                  layers[i].remove();

              }

          }

          if(app.activeDocument.metadataPreferences.documentTitle == '5x7 Signs'){

              for(var myCounter = 0; myCounter < myGraphics.length; myCounter++){

                  smallSigns(myDocument, myGraphics[myCounter], myLabelHeight, myLabelOffset, myLabelStyle);

              }

          }

          if(app.activeDocument.metadataPreferences.documentTitle == '4in Clocks'){

              for(var myCounter = 0; myCounter < myGraphics.length; myCounter++){

                  smallClocks(myDocument, myGraphics[myCounter], myLabelHeight, myLabelOffset, myLabelStyle);

              }

          }

          if(app.activeDocument.metadataPreferences.documentTitle == '8in Clocks'){

              for(var myCounter = 0; myCounter < myGraphics.length; myCounter++){

                  largeClocks(myDocument, myGraphics[myCounter], myLabelHeight, myLabelOffset, myLabelStyle);

              }

          }

          if(app.activeDocument.metadataPreferences.documentTitle == 'Plaques'){

              for(var myCounter = 0; myCounter < myGraphics.length; myCounter++){

                  plaques(myDocument, myGraphics[myCounter], myLabelHeight, myLabelOffset, myLabelStyle);

              }

          }

          if(app.activeDocument.metadataPreferences.documentTitle == '8x12 Signs'){

              for(var myCounter = 0; myCounter < myGraphics.length; myCounter++){

                  largeSigns(myDocument, myGraphics[myCounter], myLabelHeight, myLabelOffset, myLabelStyle);

              }

          }

          if(app.activeDocument.metadataPreferences.documentTitle == 'Beer Steins'){

              for(var myCounter = 0; myCounter < myGraphics.length; myCounter++){

                  beerSteins(myDocument, myGraphics[myCounter], myLabelHeight, myLabelOffset, myLabelStyle);

              }

          }

          if(app.activeDocument.metadataPreferences.documentTitle == 'Can Coolers'){

              for(var myCounter = 0; myCounter < myGraphics.length; myCounter++){

                  canCoolers(myDocument, myGraphics[myCounter], myLabelHeight, myLabelOffset, myLabelStyle);

              }

          }

          if(app.activeDocument.metadataPreferences.documentTitle == 'Coffee Mugs Wrap' || app.activeDocument.metadataPreferences.documentTitle == 'Coffee Mugs NoWrap'){

              for(var myCounter = 0; myCounter < myGraphics.length; myCounter++){

                  coffeeMugs(myDocument, myGraphics[myCounter], myLabelHeight, myLabelOffset, myLabelStyle);

              }

          }

          app.activeDocument.layers.item("labels").locked ^= 1;

      }

      function smallSigns(myDocument, myGraphic){

          myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;

          myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

          var myLabel;

          var myLink = myGraphic.itemLink;

          //Create the label layer if it does not already exist.

          var myLabelLayer = myDocument.layers.item("labels");

          try{

               myLabelLayer.name;

          }

           catch (myError){

                myLabelLayer = myDocument.layers.add({name:"labels"});

          }

          var myLabel = myLink.linkXmp.description;

          var myFrame = myGraphic.parent;

          var myLabelStyle = myDocument.paragraphStyles.item(2);

          var myLabelHeight = 24;

          myRotation = 0;

          myX1 = myFrame.geometricBounds[1];

          myY1 = myFrame.geometricBounds[2] + 14;

          myX2 = myFrame.geometricBounds[3];

          myY2 = myY1 + 24;

          var myTextFrame = myFrame.parent.textFrames.add(myLabelLayer, undefined, undefined,{rotationAngle:myRotation,geometricBounds:[myY1, myX1, myY2, myX2], contents:myLabel,});

          myTextFrame.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

          myTextFrame.parentStory.texts.item(0).appliedParagraphStyle = myLabelStyle;

          app.activeWindow.transformReferencePoint = AnchorPoint.CENTER_ANCHOR;

          myTextFrame.flipItem(Flip.HORIZONTAL);

          if((myGraphic.geometricBounds[3] > myFrame.geometricBounds[3]) || (myGraphic.horizontalScale < 85)){

              if(myFrame.locked == 1){

                  myFrame.locked = 0;

                  }

              myGraphic.rotationAngle = 90;

              myGraphic.fit(FitOptions.CONTENT_TO_FRAME);

              if(myFrame.locked == 0){

                  myFrame.locked ^= 1;

                  }

              }

          if(myGraphic.horizontalScale > 120){

              if(myFrame.locked == 1){

                  myFrame.locked = 0;

                  }

              myGraphic.rotationAngle = 0;

              myGraphic.fit(FitOptions.CONTENT_TO_FRAME);

              if(myFrame.locked == 0){

                  myFrame.locked ^= 1;

                  }

              }

      }

      function smallClocks(myDocument, myGraphic){

          myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;

          myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

          var myLabel;

          var myLink = myGraphic.itemLink;

          //Create the label layer if it does not already exist.

          var myLabelLayer = myDocument.layers.item("labels");

          try{

               myLabelLayer.name;

          }

           catch (myError){

                myLabelLayer = myDocument.layers.add({name:"labels"});

          }

          var myLabel = myLink.linkXmp.description;

          var myFrame = myGraphic.parent;

          var myLabelStyle = myDocument.paragraphStyles.item(2);

          var myLabelHeight = 24;

          myRotation = 0;

          myX1 = myFrame.geometricBounds[1];

          myY1 = myFrame.geometricBounds[2] + 15;

          if(myY1 > 400){

              myY1 = (myFrame.geometricBounds[0] - myLabelHeight - 15);

              }

          myX2 = myFrame.geometricBounds[3];

          myY2 = myY1 + myLabelHeight;

          var myTextFrame = myFrame.parent.textFrames.add(myLabelLayer, undefined, undefined,{rotationAngle:myRotation,geometricBounds:[myY1, myX1, myY2, myX2], contents:myLabel,});

          myTextFrame.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

          myTextFrame.parentStory.texts.item(0).appliedParagraphStyle = myLabelStyle;

          app.activeWindow.transformReferencePoint = AnchorPoint.CENTER_ANCHOR;

          myTextFrame.flipItem(Flip.HORIZONTAL);

      }

      function largeClocks(myDocument, myGraphic){

          myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;

          myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

          var myLabel;

          var myLink = myGraphic.itemLink;

          //Create the label layer if it does not already exist.

          var myLabelLayer = myDocument.layers.item("labels");

          try{

               myLabelLayer.name;

          }

           catch (myError){

                myLabelLayer = myDocument.layers.add({name:"labels"});

          }

          var myLabel = myLink.linkXmp.description;

          var myFrame = myGraphic.parent;

          var myLabelStyle = myDocument.paragraphStyles.item(2);

          var myLabelHeight = 24;

          myRotation = 0;

          myX1 = myFrame.geometricBounds[1];

          myY1 = myFrame.geometricBounds[2] + 20;

          myX2 = myFrame.geometricBounds[3];

          myY2 = myY1 + myLabelHeight;

          var myTextFrame = myFrame.parent.textFrames.add(myLabelLayer, undefined, undefined,{rotationAngle:myRotation,geometricBounds:[myY1, myX1, myY2, myX2], contents:myLabel,});

          myTextFrame.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

          myTextFrame.parentStory.texts.item(0).appliedParagraphStyle = myLabelStyle;

          app.activeWindow.transformReferencePoint = AnchorPoint.CENTER_ANCHOR;

          myTextFrame.flipItem(Flip.HORIZONTAL);

      }

      function plaques(myDocument, myGraphic){

          myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;

          myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

          var myLabel;

          var myLink = myGraphic.itemLink;

          //Create the label layer if it does not already exist.

          var myLabelLayer = myDocument.layers.item("labels");

          try{

               myLabelLayer.name;

          }

           catch (myError){

                myLabelLayer = myDocument.layers.add({name:"labels"});

          }

          var myLabel = myLink.linkXmp.description;

          var myFrame = myGraphic.parent;

          var myLabelStyle = myDocument.paragraphStyles.item(2);

          var myLabelHeight = 24;

          myRotation = 90;

          myX1 = 37;

          myY1 = myFrame.geometricBounds[2];

          myX2 = 200;

          myY2 = myY1 + 50;

          app.activeWindow.transformReferencePoint = AnchorPoint.TOP_LEFT_ANCHOR;

          var myTextFrame = myFrame.parent.textFrames.add(myLabelLayer, undefined, undefined,{rotationAngle:myRotation,geometricBounds:[myY1, myX1, myY2, myX2], contents:myLabel,});

          myTextFrame.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

          myTextFrame.parentStory.texts.item(0).appliedParagraphStyle = myLabelStyle;

          app.activeWindow.transformReferencePoint = AnchorPoint.CENTER_ANCHOR;

          myTextFrame.flipItem(Flip.VERTICAL);

      }

      function largeSigns(myDocument, myGraphic){

          myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;

          myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

          var myLabel;

          var myLink = myGraphic.itemLink;

          //Create the label layer if it does not already exist.

          var myLabelLayer = myDocument.layers.item("labels");

          try{

               myLabelLayer.name;

          }

           catch (myError){

                myLabelLayer = myDocument.layers.add({name:"labels"});

          }

          var myLabel = myLink.linkXmp.description;

          var myFrame = myGraphic.parent;

          var myLabelStyle = myDocument.paragraphStyles.item(2);

          var myLabelHeight = 24;

          myRotation = 0;

          myX1 = myFrame.geometricBounds[1];

          myY1 = myFrame.geometricBounds[2];

          myX2 = myFrame.geometricBounds[3];

          myY2 = myY1 + myLabelHeight;

          if((myFrame.geometricBounds[3] + myFrame.geometricBounds[1] > 860) && (myFrame.geometricBounds[0] + myFrame.geometricBounds[2] > 570)){

              app.activeWindow.transformReferencePoint = AnchorPoint.TOP_LEFT_ANCHOR;

              myRotation = -90;

              myX1 = myFrame.geometricBounds[0] + 32.25;

              myX2 = myFrame.geometricBounds[2] + 32.25;

              myY1 = myFrame.geometricBounds[1] - 53.75;

              myY2 = myY1 + myLabelHeight;

              }

          var myTextFrame = myFrame.parent.textFrames.add(myLabelLayer, undefined, undefined,{rotationAngle:myRotation,geometricBounds:[myY1, myX1, myY2, myX2], contents:myLabel,});

          myTextFrame.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

          myTextFrame.parentStory.texts.item(0).appliedParagraphStyle = myLabelStyle;

          app.activeWindow.transformReferencePoint = AnchorPoint.CENTER_ANCHOR;

          myTextFrame.flipItem(Flip.VERTICAL);

          if(myGraphic.geometricBounds[2] > myFrame.geometricBounds[2]){

              if(myFrame.locked == 1){

                  myFrame.locked = 0;

                  }

              myGraphic.rotationAngle = -90;

              myGraphic.fit(FitOptions.CONTENT_TO_FRAME);

              if(myFrame.locked == 0){

                  myFrame.locked ^= 1;

                  }

              }

          if(myGraphic.horizontalScale < 70){

              if(myFrame.locked == 1){

                  myFrame.locked = 0;

                  }

              myGraphic.rotationAngle = 0;

              myGraphic.fit(FitOptions.CONTENT_TO_FRAME);

              if(myFrame.locked == 0){

                  myFrame.locked ^= 1;

                  }

              }

      }

      function beerSteins(myDocument, myGraphic){

          myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;

          myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

          var myLabel;

          var myLink = myGraphic.itemLink;

          //Create the label layer if it does not already exist.

          var myLabelLayer = myDocument.layers.item("labels");

          try{

               myLabelLayer.name;

          }

           catch (myError){

                myLabelLayer = myDocument.layers.add({name:"labels"});

          }

          var myLabel = myLink.linkXmp.description;

          var myFrame = myGraphic.parent;

          var myLabelStyle = myDocument.paragraphStyles.item(2);

          var myLabelHeight = 28.498;

          var offset = 3;

          myRotation = 0;

          myX1 = myFrame.geometricBounds[3] + 54;

          myY1 = myFrame.geometricBounds[0];

          if(myY1 > 350){

              myY1 = (myFrame.geometricBounds[0] - myLabelHeight - offset);

              myRotation = 180;

              }

          myX2 = myFrame.geometricBounds[1];

          myY2 = myY1 + myLabelHeight;

          var myTextFrame = myFrame.parent.textFrames.add(myLabelLayer, undefined, undefined,{rotationAngle:myRotation,geometricBounds:[myY1, myX1, myY2, myX2], contents:myLabel,});

          myTextFrame.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

          myTextFrame.parentStory.texts.item(0).appliedParagraphStyle = myLabelStyle;

          app.activeWindow.transformReferencePoint = AnchorPoint.TOP_LEFT_ANCHOR;

          myTextFrame.rotationAngle = -90;

          app.activeWindow.transformReferencePoint = AnchorPoint.CENTER_ANCHOR;

          myTextFrame.flipItem(Flip.VERTICAL);

      }

      function canCoolers(myDocument, myGraphic){

          myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;

          myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

          var myLabel;

          var myLink = myGraphic.itemLink;

          //Create the label layer if it does not already exist.

          var myLabelLayer = myDocument.layers.item("labels");

          try{

               myLabelLayer.name;

          }

           catch (myError){

                myLabelLayer = myDocument.layers.add({name:"labels"});

          }

          var myLabel = myLink.linkXmp.description;

          var myFrame = myGraphic.parent;

          var myLabelStyle = myDocument.paragraphStyles.item(2);

          var myLabelHeight = 24;

          myRotation = 0;

          myX1 = 480;

          myY1 = 467;

          myX2 = 697;

          myY2 = 491;

          var myTextFrame = myFrame.parent.textFrames.add(myLabelLayer, undefined, undefined,{rotationAngle:myRotation,geometricBounds:[myY1, myX1, myY2, myX2], contents:myLabel,});

          myTextFrame.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

          myTextFrame.parentStory.texts.item(0).appliedParagraphStyle = myLabelStyle;

          app.activeWindow.transformReferencePoint = AnchorPoint.CENTER_ANCHOR;

      }

      function coffeeMugs(myDocument, myGraphic){

          myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;

          myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

          var myLabel;

          var myLink = myGraphic.itemLink;

          //Create the label layer if it does not already exist.

          var myLabelLayer = myDocument.layers.item("labels");

          try{

               myLabelLayer.name;

          }

           catch (myError){

                myLabelLayer = myDocument.layers.add({name:"labels"});

          }

          var myLabel = myLink.linkXmp.description;

          var myFrame = myGraphic.parent;

          var myLabelStyle = myDocument.paragraphStyles.item(2);

          var myLabelHeight = 24;

          var offset = 5;

          myRotation = 0;

          myX1 = myFrame.geometricBounds[1];

          myY1 = myFrame.geometricBounds[2] + offset;

          if(myY1 > 350){

              myY1 = (myFrame.geometricBounds[0] - myLabelHeight - offset);

              myRotation = 180;

              }

          myX2 = myFrame.geometricBounds[3];

          myY2 = myY1 + myLabelHeight;

          var myTextFrame = myFrame.parent.textFrames.add(myLabelLayer, undefined, undefined,{rotationAngle:myRotation,geometricBounds:[myY1, myX1, myY2, myX2], contents:myLabel,});

          myTextFrame.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

          myTextFrame.parentStory.texts.item(0).appliedParagraphStyle = myLabelStyle;

          app.activeWindow.transformReferencePoint = AnchorPoint.CENTER_ANCHOR;

          myTextFrame.flipItem(Flip.HORIZONTAL);

      }

      function myGetParagraphStyleNames(){

          var myStyleNames = app.documents.item(0).paragraphStyles.everyItem().name;

          return myStyleNames;

      }

      };

          menuItem3Handler = function( /*onInvoke*/ ){

              var placeAction = app.menuActions.item("$ID/Place...");

              placeAction.invoke();

          };

          menuItem4Handler = function( /*onInvoke*/ ){

              var printAction = app.menuActions.item("$ID/Print...");

              printAction.invoke();

          };

          subMenuItem1Handler = function( /*onInvoke*/ ){

              app.doScript( File(myFolder + 'File-Three.jsx') );

          }; 

          subMenuItem2Handler = function( /*onInvoke*/ ){

              app.doScript( File(myFolder + 'File-Four.jsx') );

          }; 

       

          // SET GENERAL VARIABLES

          try {

              myFolder = app.activeScript;

          }

          catch(e) {

              myFolder = File(e.fileName);  // we are running from the ESTK

          }

          myFolder = myFolder.parent.parent  + '/' ;  //this file is in the "startup scripts" subfolder

       

          var menuItem1T = "Add Page",

             menuItem2T = "Add Labels",

             menuItem3T = "Place...  Ctrl+D",

             menuItem4T = "Print... Ctrl+P",

             subMenuItem1T = "My SubMenu Item 1",

             subMenuItem2T = "My SubMenu Item 2",

             menuT = "Sublimation",

             subT = "Sub Menu",

             subs = app.menus.item("$ID/Main").submenus, mnu;

          var refItem = app.menus.item("$ID/Main").submenus.item("$ID/&Layout");

       

          // CREATE MENU ITEMS

          subMenu1 = app.scriptMenuActions.item(menuItem1T);

          if( subMenu1 == null ) {

              subMenu1 = app.scriptMenuActions.add(menuItem1T);

          }

          subMenu1.eventListeners.add("onInvoke", menuItem1Handler);

       

          subMenu2 = app.scriptMenuActions.item(menuItem2T);

          if( subMenu2 == null ) {

              subMenu2 = app.scriptMenuActions.add(menuItem2T);

          }

          subMenu2.eventListeners.add("onInvoke", menuItem2Handler);

       

          subMenu3 = app.scriptMenuActions.item(menuItem3T);

          if( subMenu3 == null ) {

              subMenu3 = app.scriptMenuActions.add(menuItem3T);

          }

          subMenu3.eventListeners.add("onInvoke", menuItem3Handler);

       

          subMenu4 = app.scriptMenuActions.item(menuItem4T);

          if( subMenu4 == null ) {

              subMenu4 = app.scriptMenuActions.add(menuItem4T);

          }

          subMenu4.eventListeners.add("onInvoke", menuItem4Handler);

       

          subSubMenu1 = app.scriptMenuActions.item(subMenuItem1T);

          if( subSubMenu1 == null ) {

              subSubMenu1 = app.scriptMenuActions.add(subMenuItem1T);

          }

          subSubMenu1.eventListeners.add("onInvoke", subMenuItem1Handler);

       

          subSubMenu2 = app.scriptMenuActions.item(subMenuItem2T);

          if( subSubMenu2 == null ) {

              subSubMenu2 = app.scriptMenuActions.add(subMenuItem2T);

          }

          subSubMenu2.eventListeners.add("onInvoke", subMenuItem2Handler);

       

       

          mnu = subs.item(menuT);

          if( mnu == null ) {

              mnu = subs.add(menuT, LocationOptions.after, refItem);

          }

       

          subsSubs = app.menus.item( '$ID/Main' ).submenus.item( menuT ).submenus;

          mnu.menuItems.add(subMenu1);

          mnu.menuSeparators.add;

          mnu.menuItems.add(subMenu2);

          mnu.menuItems.add(subMenu3);

          mnu.menuItems.add(subMenu4);

      };

       

      Any help is much appreciated!