2 Replies Latest reply on Jun 11, 2009 1:38 AM by Set Screen name

    Why Script writes err?

    Set Screen name

      Tihs simple code cause err:


      Set myItem = myInd.Selection.Item(1)

      cntPag = myItem.Parent.Name 'current page number
      ''rr = cntPag + 1
      Set mPageNext = myDoc.Pages.Item(cntPag + 1) '''''' writes "Invalid parametr"!!!



      Set mPageNext = myDoc.Pages.Item(10) ''''' does work


      Was ist das?





      cntPag = Val(myItem.Parent.Name) 'current page number
      Set mPageNext = myDoc.Pages.Item(cntPag + 1) '''' again err!


      Its not var_type promblem?

        • 1. Re: Why Script writes err?
          Andreas Jansson Level 2



          To begin with, what language is this? Is it VBscript, VB6 or VB.Net?

          It's a good practict to put something like [VBS CS3] in the beginning of the message title, indicating script language and InDesign version.


          You should probably inspect the contents of cntPag when the error occurs, perhaps it's already up at the last page? The Invalid parameter message sound like there's something else though... What is cntPag declared as? If it's declared as "Dim cntPag as String" then perhaps you would need another variable to assign the Val-result, and use.


          Also, if you are dealing with a 0-based index, then page name 1 would be index 0 in the pages collection, and if that's the case you should not add 1 to the page name.


          Perhaps you would also like to have a look at the page.documentOffset property, if it suits you better.


          Best regards,

          Andreas Jansson

          • 2. Re: Why Script writes err?
            Set Screen name Level 1

            OK. I'll try to mark next posts. My mark is [VBA CS3].

            I used page.DocumentOffset instead of page.Name. And this worked!


            More over, after correct var declaration, property .Name also did work!


            Thanks very much, Andreas.