How to make my script ignore pages 1 and 2?

Hi all. I'm a complete beginnger at all of this so thank you in advance for all you're help, I really appreciated it.
I have a JavaScript that I've been working on, and with help from people on here it's working really well. I uses a combination of GREP expressions and checks the entire document and then applies pre-made Character Style that have been set up in the InDesign Templates. (By the way I'm using CS6).
My latest problem is that I don't want this to affect page 1 or 2 as the templates are layed out in spreads so these are the front and back cover.
Is there a way I can get the script to ignore page 1 and 2?
If not, I thought another way round would be to only have the script run on highlighted text, but I'd prefere to just ignore pages 1 and 2.
Any and all help would be greatly appreciated.
Thanks again,
Scorpio

Hi Scorpio17523 and Kai,
> As far as I know, it is not possible to search for specific pages?
My guess is that you can, in fact, use Pages.itemByRange(2,-1)... in order to reach a valid plural specifier that holds a findGrep (or changeGrep) method—like TextFrame or Paragraph. This is a powerful way to run a GREP query in a single command.
Say you want to apply some character style (MyCharStyle) to every word that begin with a 'A' or 'a', considering all textframes except those of page 1 and 2 (i.e. index 0 and 1). This can be done in a single pass without any loop, as shown below:
// Your settings
var GREP_PATTERN = '\\<[aA][\\l\\u]+';
var CHAR_STYLE_NAME = 'MyCharStyle';
// Variables
var doc = app.activeDocument,
    cStyle = doc.characterStyles.itemByName(CHAR_STYLE_NAME),
    target = doc.pages.itemByRange(2,-1).textFrames.everyItem().paragraphs.everyItem(),
    nr;
// Set GREP, and run!
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = GREP_PATTERN;
app.changeGrepPreferences.appliedCharacterStyle = cStyle;
nr = target.changeGrep().length;
alert( nr + " expressions have been changed." );
The important part is:
target = doc.pages.itemByRange(2,-1).textFrames.everyItem().paragraphs.everyItem()
This allows to filter page indices 0 and 1 inside the specifier. As a result, target is a 'plural' Paragraph object which represents every desired text and can then invoke its changeGrep() method.
Note that we could as well invoke changeGrep() from a plural TextFrame—i.e.: ...textFrames.everyItem()—but the GREP command will lead to a runtime error if some textframe of the collection is empty. That issue does not occur if one extends the specifier to ...paragraphs.everyItem()—unless all the frames are empty!
Hope that helps.
@+
Marc

Similar Messages

  • How to Make a Printable Results Page in Adobe Captivate 8

    Hi Captivate Developers!
    We made a really cool Captivate tip that I think you will enjoy. This tip allows your learners print-friendly results in Adobe Captivate 8. We also include the code needed to make it work and is actually pretty easy. It also includes videos for each step. Hope you like it!
    http://elearningbrothers.com/how-to-make-a-printable-results-page-in-adobe-captivate-8/

    If you have a dynamic web site (database driven), use PHP or ASP data queries.
    If your site is static (no databases), look at the links below:
    Zoom Search Engine software
    http://www.wrensoft.com/zoom/index.html
    Free Find
    http://www.freefind.com/
    Pico Search
    http://www.picosearch.com/
    Google Site Search -
    http://www.google.com/sitesearch/
    Web Assist DW Tools for Google (free)
    http://www.webassist.com/free-downloads/dreamweaver-extensions/dreamweaver-tools-for-googl e/
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • Flash cs3: how to make moving/scrolling photo menu left and right?

    http://media.moma.org/subsites/2008/miro/flashsite/index.html
    - click continue, then relative size link
    How can I do this with lash cs3: how to make moving/scrolling
    photo menu left and right?
    When you move left and right and paintings move. and when you
    click on a painting, you see the the title and it links to another
    page on the site.

    scene_mc start at x = -550... x wide is 2164 px
    now I have this and its working...
    navL_mc.addEventListener(MouseEvent.MOUSE_OVER, navL_Over);
    navL_mc.addEventListener(MouseEvent.MOUSE_OUT, navL_Out);
    function navL_Over(e:MouseEvent){
              if(scena_mc.x == 0){
                                  scena_mc.x == 0;
              else if(scena_mc.x <= -10){
                                  scena_mc.x += 10;
                                  navL_mc.addEventListener(Event.ENTER_FRAME, runL);
    function runL(e:Event):void{
              if(scena_mc.x == 0){
                                  scena_mc.x == 0;
              else if(scena_mc.x <= -10){
                                  scena_mc.x += 10;
    function navL_Out(e:MouseEvent){
              navL_mc.removeEventListener(Event.ENTER_FRAME, runL);
    navR_mc.addEventListener(MouseEvent.MOUSE_OVER, navR_Over);
    navR_mc.addEventListener(MouseEvent.MOUSE_OUT, navR_Out);
    function navR_Over(e:MouseEvent){
              if(scena_mc.x == -1164){
                                  scena_mc.x == -1164;
              else if(scena_mc.x >= -1154){
                                  scena_mc.x -= 10;
                                  navR_mc.addEventListener(Event.ENTER_FRAME, runR);
    function runR(e:Event):void{
              if(scena_mc.x == -1164){
                                  scena_mc.x == -1164;
              else if(scena_mc.x >= -1154){
                                  scena_mc.x -= 10;
    function navR_Out(e:MouseEvent){
              navR_mc.removeEventListener(Event.ENTER_FRAME, runR);

  • How to make a commentary track in iDVD and iMovie 6

    Could someone please explain how to make a commentary track using iMovie6 and iDVD? I think I will be able to import the commentary track onto the second sound track in iMovie 6 with no problem. I just can't figure out how to make it an optional track in the final DVD.

    Yes, you can put the commentary track on the second sound track in 06. You can also attach a mic and make the commentary as a recording. I will caution that you will need to depress any original sounds associated with the film so that it does not sound like a garbled mess with both tracks competing. I imagine you know how to grab the volume level line in the audio track and nudge it lower or higher?
    I also don't see any other option than including two versions of the film on the DVD. Pretty simple fix if it will fit... I would export the plain film first before adding the other audio (or you can simply uncheck one of the audio tracks while exporting to mute it).
    Terri

  • How to make comnapy code defalut got 100 and 1001 in the PNP screen

    Hi Expart ,
    can u tell me my que how to make comnapy code defalut got 100 and 1001 in the PNP screen in HR reporting?
    Regards
    Razz

    Use the below code in the   INITIALIZATION   
                     INITIALIZATION                                      *
    initialization .
    " Make Default values for Company Code 2100 & 2200
      PNPBUKRS-LOW  = '2100'.
      PNPBUKRS-HIGH = '2200'.
      append PNPBUKRS.
    regards
    .....lakhan

  • How to make Nokia Suite remember the position and ...

    how to make Nokia Suite remember the position and the size i set it?
    because everytime i start it, it defaults in the middle of the screen and in the smallest possible size.
    Nokia Suite 3.3.86
    Windows Vista
    Greece Nokia X6 RM-559 v40.0.002

    Again, are you talking about genuine Nokia firmware, not any of some 3rd-party customised versions?
    For officially released firmware, you may force Nokia Suite to reinstall even if your firmware is already up to date. This feature might be missed in its GUI as its link is "hidden" in the prompt message, not on a button or highlighted with underscore. Try Nokia Suite, once the phone is connected, click the icon of Software Update on the top, then click the word "reinstall" in the prompted message.
    bbao
    * If this post helped you, please click the white Kudo star.
    * If this post has solved your issue, please click Accept as Solution.

  • CS6 Fluid Grids - how to make images resize when page is resized? [was: Hello]

    I am new to fluid grid layouts in Dreamweaver cs6, I want to insert a GIF file on my index page but I do not know how to make it so when the page shrinks the GIF or image shrinks as well. The only code that I have found is
    img, {
        max-width: 100%;
    But this code already exists in the css file when you create a new fluid grid based layout
    img, object, embed, video {
        max-width: 100%;
    can anyone help a newbie please..

    this is my source code
    <!doctype html>
    <!--[if lt IE 7]> <html class="ie6 oldie"> <![endif]-->
    <!--[if IE 7]>    <html class="ie7 oldie"> <![endif]-->
    <!--[if IE 8]>    <html class="ie8 oldie"> <![endif]-->
    <!--[if gt IE 8]><!-->
    <html class="">
    <!--<![endif]-->
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Kyle Childress Foundation</title>
    <link href="boilerplate.css" rel="stylesheet" type="text/css">
    <link href="/layout.css" rel="stylesheet" type="text/css">
    <!--
    To learn more about the conditional comments around the html tags at the top of the file:
    paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
    Do the following if you're using your customized build of modernizr (http://www.modernizr.com/):
    * insert the link to your js here
    * remove the link below to the html5shiv
    * add the "no-js" class to the html tags at the top
    * you can also remove the link to respond.min.js if you included the MQ Polyfill in your modernizr build
    -->
    <!--[if lt IE 9]>
    <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <script src="respond.min.js"></script>
    </head>
    <body>
    <div class="gridContainer clearfix">
      <div id="animation"><img src="images/images/kyleanimation2014gif2.gif" alt="kylechildressfoundationanimation"></div>
    </div>
    </body>
    </html>
    this is my css
    @charset "UTF-8";
    @import url("/kyle.css");
    /* Simple fluid media
       Note: Fluid media requires that you remove the media's height and width attributes from the HTML
       http://www.alistapart.com/articles/fluid-images/
    img, object, embed, video {
        max-width: 100%;
    /* IE 6 does not support max-width so default to width 100% */
    .ie6 img {
        width:100%;
        Dreamweaver Fluid Grid Properties
        dw-num-cols-mobile:        5;
        dw-num-cols-tablet:        8;
        dw-num-cols-desktop:    10;
        dw-gutter-percentage:    25;
        Inspiration from "Responsive Web Design" by Ethan Marcotte
        http://www.alistapart.com/articles/responsive-web-design
        and Golden Grid System by Joni Korpi
        http://goldengridsystem.com/
    /* Mobile Layout: 480px and below. */
    .gridContainer {
        margin-left: auto;
        margin-right: auto;
        width: 87.36%;
        padding-left: 1.82%;
        padding-right: 1.82%;
    #LayoutDiv1 {
        clear: both;
        float: left;
        margin-left: 0;
        width: 100%;
        display: block;
    #animation {
        clear: both;
        float: left;
        margin-left: 0;
        width: 100%;
        display: block;
    #image {
        clear: both;
        float: left;
        margin-left: 0;
        width: 100%;
        display: block;
    /* Tablet Layout: 481px to 768px. Inherits styles from: Mobile Layout. */
    @media only screen and (min-width: 481px) {
    .gridContainer {
        width: 90.675%;
        padding-left: 1.1625%;
        padding-right: 1.1625%;
    #LayoutDiv1 {
        clear: both;
        float: left;
        margin-left: 0;
        width: 100%;
        display: block;
    #animation {
        clear: both;
        float: left;
        margin-left: 0;
        width: 100%;
        display: block;
    #image {
        clear: both;
        float: left;
        margin-left: 0;
        width: 100%;
        display: block;
    /* Desktop Layout: 769px to a max of 1232px.  Inherits styles from: Mobile Layout and Tablet Layout. */
    @media only screen and (min-width: 769px) {
    .gridContainer {
        width: 88.2%;
        max-width: 1232px;
        padding-left: 0.9%;
        padding-right: 0.9%;
        margin: auto;
    #LayoutDiv1 {
        clear: both;
        float: left;
        margin-left: 0;
        width: 100%;
        display: block;
    #animation {
        clear: both;
        float: left;
        margin-left: 0;
        width: 100%;
        display: block;
    #image {
        clear: both;
        float: left;
        margin-left: 0;
        width: 100%;
        display: block;
    the animation GIF is 700 x 908
    I changed the code from max-width to just width 100% but it still did not work ,, please help

  • How to make AE script folder?

    Hi, i want to ask something about script in after effect CS6. I have many script in my AE and I think its quite difficult to find the script i want. So, how to make script folder in AE or maybe group of script? So if I want to use the script i can find it easier....
    Thank you and sorry for my bad english...

    // create a new FolderItem in project, with name “comps”
    var compFolder = app.project. items.addFolder(“comps”);
    AE CS3 Scripting guide, page 78

  • How to make my dynamic form pages flow correctly?

    I have created a dynamic form which has multiple questions with expandable text fields that will take multiple pages once completed.  I do not know how to make the form flow correctly past the first page.  I can attach the form if I knew how to do that.

    Thank you Paul.  Your editing assistance was greatly appreciated. I think I now understand that there should be only one page subform that is flowed, regardless of how many text box objects I have in my questionnaire. This did the trick.

  • How to make shapes appear behind page header/footer in Pages '09

    In a Pages (v4.0.2) page layout document, I'm trying to make a gradient as the page background. Since there's no built-in way to do this (as far as my googling shows), I've tried what others have suggested:
    1. Create a new shape and resize it so it fills the entire page
    2. Go to Arrange > Send to Back
    3. There's no step three!
    This work great for most of the page. However, the page header and footer are always hidden by the shape, and I can't find a way to get them to lay +in front+ of the shape. How can I get the background shape behind the header & footer?
    Thanks for your help,
    Mike

    fruhulda wrote:
    As far as I know you don't need to send the shape to the back.
    Choose in the menu Format > Advanced > Move Object to Section Master
    Are you sure that we may do that with a shape?
    Here the item is greyed
    Yvan KOENIG (VALLAURIS, France) samedi 29 août 2009 21:28:21

  • How to make a script to convert RGB to CMYK as black 100%?

    Hi guy
    my customer sent me a book (144 pages) for print but all of them are RGB and Tiff, she scan them. there are on the page some texts and pictures. The text are R=30 G=30 B=30.I think if I can make a script I will do it very soon to black 100%, but unfortunately I dont know anything to make script 
    anybody can help me ?anybody can make it for me ?

    We need to know some more information.
    1. The book consists of 144 pages, and each page is in fact an RGB image in TIFF format.
        Correct?
        That means, the text is already rasterized, but with low resolution (no more than 300ppi).
        A very bad starting point, in my humble opinion. For offset printing this is not acceptable.
    2. Is the printing process offset printing or by digital printing?
    Nevertheless we may think about a conversion of these images into CMYK K-only (one plate
    per page) . 
    a) Increase contrast until R=G=B=0 for text.
    b) Convert each image into Grayscale, using a so-called Black-Ink-Profile, for instance
        Black-Ink-ISOCoated-v2-eci (can be explained later)
    c) Make empty CMYK image, here for  ISOCoated-v2-eci, and paste the Grayscale into the
        K-channel. All further handling happens as CMYK file for the process ISOCoated-v2-eci.
        Void plates CMY don't matter.
        Post #12 here:
        Re: Colour shift (from CMYK = 0 0 0 20 to Grayscale K = 22 !)
    All this can be done by an action (I hope so...).
    Much better would be a new start by InDesign with typographical text (K-only vector instead of raster)
    with images in RGB or CMYK, taking into account the intended process.
    Note: Photoshop can deliver vector text, if exported as PDF.
    Best regards --Gernot Hoffmann

  • How to make powershell script.

    How to make script that copy content from notepad to other notepad and reverse the text?

    If you mean a .txt file then there's three aspects to your question.
    Open a file and read the text
    Reverse the text
    Save the text into a new file
    For point one, this technet article is good:
    http://technet.microsoft.com/en-us/library/ee692806.aspx
    For point two you could turn the text into one or more strings, then convert those into arrays, loop through them and then re-assemble them. This article shows you most of that:
    http://technet.microsoft.com/en-us/library/ee692804.aspx
    And finally you need to save that text as a file, there's lots of ways but the Out-File cmdlet is the simplest.
    This might also be of use:
    http://www.ehow.com/how_7174023_write-basic-powershell-script.html

  • How to make a script for expand column width

    Hi experts,
    Is that possible to make a script for expand the column width aim to let the columns show up all the overset text?
    Regard
    John

    Hi John,
    As Uwe advised it would be wise to put a stop on any while loop in case the condition is never fulfilled which would mean the script will break.
    Without knowing what specifically you are working on you could make the below amendments to do this.
    myTables = app.documents[0].stories.everyItem().tables.everyItem().getElements();
    for (var t = 0; t < myTables.length; t++) {
        BE_resizeColumnsToFitContents(myTables[t], 200);
    function BE_resizeColumnsToFitContents(tableToEdit, tableMaxWidth) {
        for (var i = 0; i < tableToEdit.columns.length; i++) {
            while (tableToEdit.columns[i].overflows === true) {
                if (tableToEdit.width < tableMaxWidth) {
                    tableToEdit.columns[i].width += 1;
                    tableToEdit.columns[i].recompose();
                else {
                    alert("Column " + i + " contents too large for column.");
                    break;
    I won't put any extra functions in this because it might not be what you're after. To use this you just define the table width as a second argument to the function (but you could change this parameter to something else, like page, column or cell width). And, if you want to have a fail action you just put it in the 'else' part.
    Brett

  • Can someone help me in learning how to make business cards using pages

    can someone please help me in learning how to make business cards using pages

    You could jump start the process with an Avery MS Word 8-up business card template as a free download. Either version of Pages will digest it nicely. Once you load it into Pages, do a File > Save As Template.. , add it to Chooser, and give it your name choice. Both versions of Pages will remove the printer registration marks in all four template corners. The free LibreOffice Writer retains them.

  • How To make certain that a page is removed from memory, silverlight

    
    Hello,
    I have a big solution with several branches. These branches was tested individually for errors and memory issues, using VS profiler and debugger. A final solution was found that at highest with animations and music peaked to 100mb, of course high but should
    not be an issue for Windows phone applications, even for low end devices. The branches was then collected to one main branch. A new test was run, and suddenly the memory spiked up towards 200mb and crashed on phones and emulators with out of memory exception.
    We at the team then tried:
    protected override void OnNavigatedTo(NavigationEventArgs e)
    if (App.RootFrame.CanGoBack)
    App.RootFrame.RemoveBackEntry();
    GC.Collect();
    base.OnNavigatedTo(e);
    This was discussed on forums to help with page memory leakage, this however did not solve the issue. We therefore wanted to investigate if pages and other elements got deconstructed and GC.Collected. This we did by implementing deconstructors:
    ~SecondScreen()
    In_Game_Crest = null;
    currentViewModel = null;
    This confirmed our fears that the pages, popups and controls did not get garbage collected, even if we sat everything to null, or
    set everything to private functions. Our code is implemented in a MVVM structure, we therefore looked to ViewModelLocator, and removed the servicelocator, as to force a new viewmodel creation for every page creation.
    This showed that the viewmodels got garbage collected upon navigation, but the views and usercontrols did not. We therefore searched around for the issue and found some links that could help us, referring to IDisposable, we therefore tried with the following
    implementation:
    private bool disposed = false;
    public void Dispose()
    Dispose(true);
    // Take yourself off the Finalization queue
    // to prevent finalization code for this object
    // from executing a second time.
    GC.SuppressFinalize(this);
    protected virtual void Dispose(bool disposing)
    // Check to see if Dispose has already been called.
    if(!this.disposed)
    // If disposing equals true, dispose all managed
    // and unmanaged resources.
    if(disposing)
    // Dispose managed resources.
    currentView = null;
    popup = null;
    Image1 = null;
    Image2 = null;
    // Release unmanaged resources. If disposing is false,
    // only the following code is executed.
    this.Content = null;
    // Note that this is not thread safe.
    // Another thread could start disposing the object
    // after the managed resources are disposed,
    // but before the disposed flag is set to true.
    // If thread safety is necessary, it must be
    // implemented by the client.
    disposed = true;
    // Use C# destructor syntax for finalization code.
    // This destructor will run only if the Dispose method
    // does not get called.
    // It gives your base class the opportunity to finalize.
    // Do not provide destructors in types derived from this class.
    ~FirstPage()
    Dispose(false);
    protected override void OnNavigatedFrom(NavigationEventArgs e)
    this.Dispose();
    base.OnNavigatedFrom(e);
    This however only increased the memory usage by 20 mb, for every call to dispose. Which hopefully would mean that we have misunderstood the use of IDisposable.
    Questions:
    Therefore quite confused, I have learned from my similar question on Stackoverflow, that I should use the VS profiler more intently to find references, but I have not succeeded in finding anything with the profiler. And I do not understand why the
    deconstructors are not fired when I know no references exists.
    Therefore would it help to implement IDisposable and how should it be done in a windows phone Silverlight context?
    Should I do something specific when I utilize the MVVM structure?Any proposals on how to force the deletion and how to do the deletion correctly?
    Or is there some other way to go about it, to ensure that pages with all information is removed.
    Hope for any help, If you want stackoverflow points I also have the following: stackoverflow.com/questions/27744091/implementing-dispose-and-finalize-for-windows-phone-silverlight-pages/

    One way i can suggest is to use 'Using' statement(obviously if not already did that) wherever it is required to work with resources such as opening a connection to database, file operations etc. With this, the resources are disposed automatically as soon
    as 'Using' block goes out of scope.
    e.g.
    using (StreamReader reader = new StreamReader("somefile.txt"))
    your code
    http://developer.nokia.com/community/wiki/Using_Crypto%2B%2B_library_with_Windows_Phone_8

Maybe you are looking for

  • Help needed in Excel Exporting

    Hi, I got a database fieldcalled category. My report is grouped on category. Category can be Agriculture or MNO or Energy. So i am getting 3 groups thats fine and the data obtained is tested to be correct. Now wen i export the report into excel. Agri

  • How to Wirelessly sync and connect my iPhone 5 to itunes?

    Hey i just wanna no if there is a way to sync iphone and contacts and trasfer songs and delete songs ect wirelessly to my mac itunes. just everything the same but without the cable Thanks

  • [Solved] Choppy Graphics + Unable to Auto Start Gnome

    Edit: Fixed the graphics issue by deleting my xorg conf and downloading my video driver again. Uncommenting fixed the boot up issue. Thanks! Alright, I just installed Arch for my first time and I'm only really having two problems. The first problem i

  • Copy Evolve Schema Evolution Fails

    Oracle 11gr2 on Linux VM SQL*Plus: Release 11.2.0.1.0 Production on Wed Feb 22 13:51:28 2012 Copyright (c) 1982, 2009, Oracle.  All rights reserved. Enter user-name: jmendez Enter password: Connected to: Oracle Database 11g Enterprise Edition Release

  • MacBook Pro running slow - opening applications, documents, photos, everything

    Hello Mac community, I am using a MacBook Pro 2010 OS X 10.9.5 Storage capacity 21.74 GB free of 249.2 GB 4 GB of memory Over the last couple of weeks, or over a month now, I have been noticing this machine is getting very slow in opening up any docu