37 Replies Latest reply on Jan 2, 2011 11:36 AM by eplicanic

    Removing guides ?

    Level 1
      How would I remove guides?

      This is what I am doing to add guides, but then what if I want to remove the guides after running this script?:
      with(myDocument.masterSpreads.item(0)){
      with(pages.item(0)){
      guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true});
      guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true});
      guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true});
      }
      with(pages.item(1)){
      guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true});
      guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true});
      guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true});
      }
      }

      thanks
        • 1. Re: Removing guides ?
          [Jongware] Most Valuable Participant
          You can only remove a certain guide if you can identify it on, say, its position -- you should loop through
          i all
          guides, check if it's on (or near! InDesign might round) the position you expect it to be, then delete. Loop until sufficiently bored.

          Hmm -- there must be a
          i better
          way of identifying your own guides. How about adding a unique label to each?

          >guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});

          Then you can delete all the guides with this label.

          Another idea pops into my mind :-) Add a
          i layer
          first, then put all the guides onto that one. Afterwards, just delete the entire layer!
          For safety, you might want to delete all guides on that new layer, then merge it with the one below it, so it won't bite you if you put any objects on it.
          • 2. Re: Removing guides ?
            Level 1
            jongware wrote: "Another idea pops into my mind Add a layer first, then put all the guides onto that one. Afterwards, just delete the entire layer!"

            Funny! That's exactly what the AddGuides example script does!:-)

            Thanks,

            Ole
            • 3. Re: Removing guides ?
              Level 1
              (Of course, if you just want to remove the guides manually so that you can
              run the script again or something, you've got Layout>Create Guides>Remove
              existing guides.)
              • 4. Re: Removing guides ?
                Level 1
                How would I delete those guides with the label??

                I went to View and hide guides but that hides all the guides...not just the ones I created.
                • 5. Re: Removing guides ?
                  Level 1
                  Use the remove() method on the guides in question.

                  Dave
                  • 6. Re: Removing guides ?
                    Level 1
                    When I try:
                    with(myDocument.masterSpreads.item(0)){
                    with(pages.item(0)){
                    guides.remove(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                    guides.remove(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                    guides.remove(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});
                    }
                    with(pages.item(1)){
                    guides.remove(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                    guides.remove(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                    guides.remove(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});
                    }
                    }

                    I get a JavaScript Error, Error number: 24
                    Error String: guides.remove is not a function
                    • 7. Re: Removing guides ?
                      Level 1
                      You're making up syntax. Do you know about the Object Model Viewer where the syntax is presented for all these features?

                      guides is a collection of guides. It does not take the remove() method. The remove() method applies to individual guides or to selected guides. You need something like:

                      myDocuments.masterSpreads[0].pages[0].guides.item("DeleteMe").remove();

                      Dave
                      • 8. Re: Removing guides ?
                        Level 1
                        Here is what I am doing:
                        myDocument = app.activeDocument;
                        myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
                        myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
                        myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;
                        //myDocument.zeroPoint = [.437,.437];
                        //Change the inch setting in lines 15, 16, 19 & 20 to set the position for horizontal guides.
                        //Measurement is from the top edge of the page.
                        //"pages.item(0)" is the left-hand virtual master page; "pages.item(1)" is the
                        //right-hand master page. Be sure to change both items.
                        //If you need more guides, add more add guide lines. If you want vertical guides, change the
                        //"orientation:HorizontalOrVertical.horizontal" to "orientation:HorizontalOrVertical.vertical"
                        with(myDocument.masterSpreads.item(0)){
                        with(pages.item(0)){
                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});
                        }
                        with(pages.item(1)){
                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});
                        }
                        }

                        I tried adding the:
                        myDocuments.masterSpreads[0].pages[0].guides.item("DeleteMe").remove();

                        And removed the guides.add lines but got errors. Where would I insert this line to delete these guides?
                        • 9. Re: Removing guides ?
                          Level 1
                          That should have been myDocument not myDocuments in that statement.

                          You should have the line anywhere in your script after the guides have been created.

                          Dave
                          • 10. Re: Removing guides ?
                            Level 1
                            I did that, and moved the line to the bottom, still nothing. Does this code create another set of guides right on top of the one that has been created but than deletes all of the guides?

                            Anyway I get a: Object is invalid error.

                            myDocument = app.activeDocument;
                            myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
                            myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
                            myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;

                            with(myDocument.masterSpreads.item(0)){
                            with(pages.item(0)){
                            guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                            guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                            guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});

                            }
                            with(pages.item(1)){
                            guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                            guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                            guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});
                            //delete these guides
                            myDocument.masterSpreads[0].pages[0].guides.item("DeleteMe").remove();
                            }
                            }

                            even if I put the line after the 2 }
                            • 11. Re: Removing guides ?
                              Level 1
                              It appears that itemByName doesn't work with guides. Use something like this after the last closing brace:
                              myGuides = myDocument.masterSpreads[0].pages[0].guides
                              
                              for (var j = myGuides.length - 1; j >= 0; j--) {
                                if (myGuides[j].label == "DeleteMe") {
                                  myGuides[j].remove();
                                }
                              }
                              You'll need a similar loop for the other page.

                              Dave
                              • 12. Re: Removing guides ?
                                Level 1
                                I did try something similar in the meantime with no results. But than I replaced with what you had. I put the code in twice with a differant varuiable name, for pages[0] and pages[1]

                                But I get: Object is invalid
                                myDocument = app.activeDocument;
                                myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
                                myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
                                myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;

                                with(myDocument.masterSpreads.item(0)){
                                with(pages.item(0)){
                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});

                                }
                                with(pages.item(1)){
                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});
                                }
                                }
                                myGuides = myDocument.masterSpreads[0].pages[0].guides
                                for (var j = myGuides.length - 1; j >= 0; j--) {
                                if (myGuides[j].label == "DeleteMe") {
                                myGuides[j].remove();
                                }
                                }
                                myGuides = myDocument.masterSpreads[1].pages[1].guides
                                for (var s = myGuides.length - 1; s >= 0; s--) {
                                if (myGuides[s].label == "DeleteMe") {
                                myGuides[s].remove();
                                }
                                }

                                I wish it was as easy to delete as it was to create!! I'm going crazy.
                                • 13. Re: Removing guides ?
                                  Level 1
                                  That code is bog-standard JavaScript, so it doesn't get any easier. It's just a shame that itemByName doesn't seem to work for guides.

                                  I've reported this as a minor failure to Adobe. Perhaps I'm being selfish with that assessment, but I've not had the need to script guides in five years, so it would be inappropriate for me to call it more than a minor failure, and what's more, I indicated that it would be acceptable to me if they just fixed the documentation. If itemByName is not supposed to work with Guides, then the OMV should not list it as being supported.

                                  Dave
                                  • 14. Re: Removing guides ?
                                    Level 1
                                    so the way the code was above should work?
                                    • 15. Re: Removing guides ?
                                      Level 1
                                      You know, you do have to look carefully at your code when you get errors. They will often point to a mistake. Use the JavaScript Console to see what is wrong.

                                      Your mistake was to try to delete guides on masterSpreads[1] -- I don't think you have more than one masterspread.

                                      Dave
                                      • 16. Re: Removing guides ?
                                        Level 1
                                        I did that, just because when I only had masterspread[0]....I got no errors, but the guides did not go away.

                                        With this script, I get no errors, but guides do not get deleted:
                                        myDocument = app.activeDocument;
                                        myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
                                        myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
                                        myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;

                                        with(myDocument.masterSpreads.item(0)){
                                        with(pages.item(0)){
                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});

                                        }
                                        with(pages.item(1)){
                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});
                                        }
                                        }
                                        myGuides = myDocument.masterSpreads[0].pages[0].guides
                                        for (var j = myGuides.length - 1; j >= 0; j--) {
                                        if (myGuides[j].label == "DeleteMe") {
                                        myGuides[j].remove();
                                        }
                                        }
                                        • 17. Re: Removing guides ?
                                          Level 1
                                          Works for me. Which version of InDesign are you using?

                                          What are you looking at when you run the script? If you look at page 1 of the document, it appears that the guides are still there because the ones on page 1 are from the right hand master page and you've not deleted those.

                                          Dave
                                          • 18. Re: Removing guides ?
                                            Level 1
                                            cs3
                                            • 19. Re: Removing guides ?
                                              Level 1
                                              So when you say it doesn't work, are you looking at the master spread in question or a live page? If you are looking at a live page, which one?

                                              Dave
                                              • 20. Re: Removing guides ?
                                                Level 1
                                                Well,
                                                The guides get applied to ALL pages that are open.
                                                So this script:
                                                myDocument = app.activeDocument;
                                                myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
                                                myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
                                                myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;

                                                with(myDocument.masterSpreads.item(0)){
                                                with(pages.item(0)){
                                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});

                                                }
                                                with(pages.item(1)){
                                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});
                                                }
                                                }

                                                Creates guides in three positions on all pages....I just want to delete those guides that I have created.

                                                But when I zoom out, there are say 5 pages in the document, and they all have the guides added when I run the above script. I just want a way to remove just those guides.

                                                Would running this:
                                                myDocument = app.activeDocument;
                                                myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
                                                myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
                                                myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;

                                                with(myDocument.masterSpreads.item(0)){
                                                with(pages.item(0)){
                                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});

                                                }
                                                with(pages.item(1)){
                                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                                                guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});
                                                }
                                                }
                                                myGuides = myDocument.masterSpreads[0].pages[0].guides
                                                for (var j = myGuides.length - 1; j >= 0; j--) {
                                                if (myGuides[j].label == "DeleteMe") {
                                                myGuides[j].remove();
                                                }
                                                }

                                                Just duplicate the guides that are already there and than try to delete them?

                                                Either way, I just want to remove the guides that I have created on all pages at positions: 1.646in, 1.912in, and 2.156in.

                                                ??
                                                • 21. Re: Removing guides ?
                                                  Level 1
                                                  Oh dear.

                                                  First off, the script won't delete all the guides because you're only deleting the ones on the even pages.

                                                  If I run that second script, it creates guides on the odd pages but not the even pages -- they are created and then deleted.

                                                  If this isn't happening for you, then you should try trashing your preferences.

                                                  Dave
                                                  • 22. Re: Removing guides ?
                                                    Level 1
                                                    Here is what my screen looks like when I run my script to create the guides:
                                                    http://www.keepitsimplekid.com/pics/myscreen.jpg
                                                    Those blue guides to the left of each page are created using this script:
                                                    myDocument = app.activeDocument;
                                                    myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
                                                    myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
                                                    myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;
                                                    //"pages.item(0)" is the left-hand virtual master page; "pages.item(1)" is the
                                                    //right-hand master page. Be sure to change both items.
                                                    with(myDocument.masterSpreads.item(0)){
                                                    with(pages.item(0)){
                                                    guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true});
                                                    guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true});
                                                    guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true});
                                                    }
                                                    with(pages.item(1)){
                                                    guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true});
                                                    guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true});
                                                    guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true});
                                                    }
                                                    }

                                                    pages.item(0)" is the left-hand virtual master page
                                                    pages.item(1)" is the right-hand virtual master page

                                                    Does that tell you anything?
                                                    • 23. Re: Removing guides ?
                                                      Level 1
                                                      That's how it should look. You've added the guides with that script but not attempted to delete them.

                                                      Dave
                                                      • 24. Re: Removing guides ?
                                                        Level 1
                                                        but deleting them does not work...do I include the remove part of the script with the part that makes the guides?...so it would work like this?:
                                                        myDocument = app.activeDocument;
                                                        myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
                                                        myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
                                                        myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;

                                                        with(myDocument.masterSpreads.item(0)){
                                                        with(pages.item(0)){
                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});

                                                        }
                                                        with(pages.item(1)){
                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});
                                                        }
                                                        }
                                                        myGuides = myDocument.masterSpreads[0].pages[0].guides
                                                        for (var j = myGuides.length - 1; j >= 0; j--) {
                                                        if (myGuides[j].label == "DeleteMe") {
                                                        myGuides[j].remove();
                                                        }
                                                        }
                                                        • 25. Re: Removing guides ?
                                                          Level 1
                                                          If I run that script, I get no guides on the left pages.

                                                          Dave
                                                          • 26. Re: Removing guides ?
                                                            Level 1
                                                            So you are running the script that....first adds the guides and then deletes?
                                                            • 27. Re: Removing guides ?
                                                              Level 1
                                                              I mean you are running this one?...and it removes them?:
                                                              myDocument = app.activeDocument;
                                                              myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
                                                              myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
                                                              myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;
                                                              with(myDocument.masterSpreads.item(0)){
                                                              with(pages.item(0)){
                                                              guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true});
                                                              guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true});
                                                              guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true});
                                                              }
                                                              with(pages.item(1)){
                                                              guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true});
                                                              guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true});
                                                              guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true});
                                                              }
                                                              }
                                                              myGuides = myDocument.masterSpreads[1].pages[1].guides
                                                              for (var s = myGuides.length - 1; s >= 0; s--) {
                                                              if (myGuides[s].label == "DeleteMe") {
                                                              myGuides[s].remove();
                                                              }
                                                              }

                                                              So this is the one that works?
                                                              • 28. Re: Removing guides ?
                                                                [Jongware] Most Valuable Participant
                                                                So it seems to me. At least it shows my idea works.

                                                                Paul, I think you'd better make
                                                                i two
                                                                scripts -- one that adds the guides, so you can do your own stuff, then another script to delete them.
                                                                Don't worry about the labels. They will be preserved, even when the first script ends. And even if you save the file and re-load it, they will still be there.
                                                                • 29. Re: Removing guides ?
                                                                  Level 1
                                                                  No. That script doesn't work because you're addressing a non-existent masterspread. You don't have a masterSpreads[1] -- or if you do, you didn't add any guides to it.

                                                                  Dave
                                                                  • 30. Re: Removing guides ?
                                                                    Level 1
                                                                    My mistake
                                                                    When I ran this script:
                                                                    myDocument = app.activeDocument;
                                                                    myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
                                                                    myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
                                                                    myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;
                                                                    with(myDocument.masterSpreads.item(0)){
                                                                    with(pages.item(0)){
                                                                    guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true});
                                                                    guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true});
                                                                    guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true});
                                                                    }
                                                                    with(pages.item(1)){
                                                                    guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true});
                                                                    guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true});
                                                                    guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true});
                                                                    }
                                                                    }
                                                                    myGuides = myDocument.masterSpreads[0].pages[0].guides
                                                                    for (var s = myGuides.length - 1; s >= 0; s--) {
                                                                    if (myGuides[s].label == "DeleteMe") {
                                                                    myGuides[s].remove();
                                                                    }
                                                                    }

                                                                    It ADDED guides, BUT did not remove them.
                                                                    • 31. Re: Removing guides ?
                                                                      Level 1
                                                                      Sorry, Meant this script...I did have the DeleteMe in there...this just creates guides:

                                                                      myDocument = app.activeDocument;
                                                                      myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
                                                                      myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
                                                                      myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;
                                                                      with(myDocument.masterSpreads.item(0)){
                                                                      with(pages.item(0)){
                                                                      guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                                                                      guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                                                                      guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});
                                                                      }
                                                                      with(pages.item(1)){
                                                                      guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                                                                      guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                                                                      guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});
                                                                      }
                                                                      }
                                                                      myGuides = myDocument.masterSpreads[0].pages[0].guides
                                                                      for (var s = myGuides.length - 1; s >= 0; s--) {
                                                                      if (myGuides[s].label == "DeleteMe") {
                                                                      myGuides[s].remove();
                                                                      }
                                                                      }

                                                                      Do I just want to create a script that has this in it:

                                                                      myGuides = myDocument.masterSpreads[0].pages[0].guides
                                                                      for (var s = myGuides.length - 1; s >= 0; s--) {
                                                                      if (myGuides[s].label == "DeleteMe") {
                                                                      myGuides[s].remove();
                                                                      }
                                                                      }
                                                                      • 32. Re: Removing guides ?
                                                                        Level 1
                                                                        OK, just ran this script on a Fresh install of indesign:
                                                                        myDocument = app.activeDocument;
                                                                        myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
                                                                        myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
                                                                        myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;
                                                                        with(myDocument.masterSpreads.item(0)){
                                                                        with(pages.item(0)){
                                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true});
                                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true});
                                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true});
                                                                        }
                                                                        with(pages.item(1)){
                                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true});
                                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true});
                                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true});
                                                                        }
                                                                        }
                                                                        myGuides = myDocument.masterSpreads[0].pages[0].guides
                                                                        for (var s = myGuides.length - 1; s >= 0; s--) {
                                                                        if (myGuides[s].label == "DeleteMe") {
                                                                        myGuides[s].remove();
                                                                        }
                                                                        }

                                                                        When I ran it with no guides on the pages it created guides on my right hand pages, but not on the left.

                                                                        When I created guides on all pages, it deleted the guides on the left hand pages, but not the right. So it is working for left hand pages. What is the diff. between a left and right page in this script?...pages[0] and pages[1] ?

                                                                        I modified the script adding pages[1]...Now, in a 4 page set it removes the first right hand page, both left hand pages...but not the second right hand page??

                                                                        myDocument = app.activeDocument;
                                                                        myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
                                                                        myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.inches;
                                                                        myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.inches;
                                                                        with(myDocument.masterSpreads.item(0)){
                                                                        with(pages.item(0)){
                                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});
                                                                        }
                                                                        with(pages.item(1)){
                                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.646 in", fitToPage:true, label:"DeleteMe"});
                                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"1.912 in", fitToPage:true, label:"DeleteMe"});
                                                                        guides.add(undefined, {orientation:HorizontalOrVertical.vertical, location:"2.156 in", fitToPage:true, label:"DeleteMe"});
                                                                        }
                                                                        }
                                                                        myGuides = myDocument.masterSpreads[0].pages[0].guides
                                                                        for (var s = myGuides.length - 1; s >= 0; s--) {
                                                                        if (myGuides[s].label == "DeleteMe") {
                                                                        myGuides[s].remove();
                                                                        }
                                                                        }
                                                                        myGuides = myDocument.masterSpreads[0].pages[1].guides
                                                                        for (var f = myGuides.length - 1; f >= 0; f--) {
                                                                        if (myGuides[f].label == "DeleteMe") {
                                                                        myGuides[f].remove();
                                                                        }
                                                                        }

                                                                        Is there something i need to add to delete guides with Label DeleteMe on all pages?
                                                                        • 33. Re: Removing guides ?
                                                                          [Jongware] Most Valuable Participant
                                                                          I think I got it.

                                                                          A Page is either the left or the right hand one of a spread. Guides, however, can span from left to right over both pages of a spread. So, logically, they are not part of a Page, but of its Spread.

                                                                          So you don't have to use the pages line in

                                                                          with(myDocument.masterSpreads.item(0)){
                                                                          
                                                                          with(pages.item(0)){


                                                                          -- you can add and remove the guides to and from masterSpreads.
                                                                          • 34. Re: Removing guides ?
                                                                            Level 1
                                                                            Jongware,

                                                                            There are two kinds of guides, those that apply to the spread and those that apply to the page. It depends what you want. If you address only the page ones, that's all you'll get and vice versa.

                                                                            Dave
                                                                            • 35. Re: Removing guides ?
                                                                              [Jongware] Most Valuable Participant
                                                                              Walking backwards & bowing out ;-)

                                                                              So Paul is doing something else -- the Unexpected? Unless his last try works, that is.
                                                                              • 36. Re: Removing guides ?
                                                                                Level 1
                                                                                I am somewhat puzzled. I've been running the scripts he's posted and they either work for me or I tell him what is wrong. So, I'm puzzled they don't work for him.

                                                                                Perhaps there's some corruption in the specific document he's working with -- I've seen that kind of thing happen recently.

                                                                                Dave
                                                                                • 37. Re: Removing guides ?
                                                                                  eplicanic

                                                                                  I found this post helpful for my own script. So thanks for posting it. This may or may not be helpful to you but, here is what I had to modify (bold) to make my script work.

                                                                                  with(myDocument.masterSpreads.item(0)){
                                                                                      for(a=0;a<pages.length; a++){
                                                                                         with(pages.item(a)){
                                                                                             //add guides
                                                                                         }  
                                                                                      }
                                                                                  }
                                                                                  

                                                                                   

                                                                                  Deleting guides worked just fine. What was not working for me was adding them on Facing and Non-Facing pages. So all I did was a add a FOR loop to take care of it.