1 2 3 Previous Next 92 Replies Latest reply on Nov 27, 2016 12:39 AM by Laubender Go to original post Branched to a new discussion.
      • 80. Re: With CS5, some things have changed
        Olav Kvern Level 1

        Fellow Scripters,

         

        It's a long story. First, referring to page items by pageItems.item("label_string")--where "label_string" was the contents of the object label--was never "intuitive." In all other cases in the DOM, item(string) is used for named objects. But, in the early days, page items didn't have names. By creating a special case for page items, we could use the contents of the label property to refer to page items. It wasn't ideal, but it worked, and everyone got used to it.

         

        I would think that users starting scripting today would expect to be able to set the object name, then use itemByName to get a reference to the object. The Layers panel is usually more visible than the Script Label panel. The only problem is that itemByName doesn't return multiple objects--and it should.

         

        Later, we realized that the simple label property was not enough--scripters needed a way to store other data on objects (and not just page items), so we added insertLabel and extractLabel. They're incredibly useful! Before we had insertLabel/extractLabel, trying to store multiple data values in the single label property was a chore--you had to use some kind of delimiter to separate the values. (My hat is off, as always, to the great engineers behind InDesign scripting, Peter Boctor and Jonathan Brown. It's sad that neither of them are still working in that area.)

         

        Note, in addition, that insertLabel/extractLabel work as expected with the label property--to write to the label, you could use:

         

        insertLabel("Label", "Some value here");

         

        ...and you can use extractLabel to get the value. Not that anyone needs to do this, it's just nice that it works.

         

        I think that the changes in this area--since the original implementation--have made things more consistent (and, one hopes, "intuitive"). Unfortunately, the changes, a.) broke something that many scripts depended on, and b.) the new approach, itemByName, does not match the capabilities of the old approach.

         

        Thanks,

         

        Ole

        • 81. Re: With CS5, some things have changed
          Econometric Level 1

          Hi everyone, I am running a VB script that I wrote for InDesign CS2 on CS5. The code below does not seem to work. Does CS5 understand Changecase? If someone knows or could point me to the CS5 VB script reference I would greatly appreciate it. I can't seem to locate any information.

           

          .Paragraphs(2).Changecase (idSentencecase)

           

          Thank you for helping!

          Mike

          • 82. Re: With CS5, some things have changed
            AdobeScripts Level 3

            Hi Mike,

            .Paragraphs(2).Changecase (idSentencecase)

            Try to use numbers:

             

            Const idSentencecase = 1667461987 (&H63637363)

                Member of InDesign.idChangecaseMode

                Makes the first letter of each sentence uppercase.

             

               .Paragraphs(2).Changecase (1667461987)

             

            Are you sure there is 2nd Paragraph ?

            What error do you have ?

            Or what is the type of the Text object you try to modify ?

             

            robin

            www.adobescripts.co.uk

            • 83. Re: With CS5, some things have changed
              Econometric Level 1

              Using the number worked perfectly. Thank you!!

              • 84. Re: With CS5, some things have changed
                Econometric Level 1

                Can anyone point me to a CS5 VB script reference? Having trouble locating one.

                 

                Thank you,

                Mike

                • 85. Re: With CS5, some things have changed
                  AdobeScripts Level 3

                  You won't find it - because it doesn't exist ...

                   

                  Try this:

                  http://www.jongware.com/idjshelp.html

                  It's for JS - but should be helpful.

                   

                  Or if you have M$ Office - you can add reference to "Resources for Visual Basic.tlb" file and use built-in Visual Basic Editor.

                   

                  robin

                  www.adobescripts.com

                  • 86. Re: With CS5, some things have changed
                    Econometric Level 1

                    I have noticed that in the situation of a two page spread, the left and right pages in CS2 will have different parent IDs, while in CS5 they will have the same parent IDs. I am trying to add pages to a document after a page of my choosing, and have the new page come in next.

                     

                    This is my CS2 code:

                     

                    X = .Parent.ID

                    With idDoc.Pages.Add(at:=idAfter, reference:=idDoc.Pages.ItemByID(X))

                     

                    I am wondering if there is a way to set the "reference:" to place a new page by page .ParentPage, since the .Parent.ID is ambiguous?

                     

                    Mike

                    • 87. Re: With CS5, some things have changed
                      AdobeScripts Level 3
                      I am wondering if there is a way to set the "reference:" to place a new page by page .ParentPage, since the .Parent.ID is ambiguous?

                       

                      According to VB Reference Guide:

                       

                      Function Add([At As idLocationOptions = idUnknown], [Reference]) As Page

                          Member of InDesign.Pages

                          Creates a new page.

                          Return value: The new page/.

                          At: The location of the new page relative to the reference object or within the document or spread. .

                          Reference: eference object. Note: Required when the at parameter value specifies before or after. Type: Page, Spread, MasterSpread or Document

                       

                      So your reference can be just the page. If you know the page after which you want to add new page - just use it - without reffering to Pages collection of the Document:

                       

                      With idDoc.Pages.Add(at:=idAfter, reference:=myPage)

                       

                      Beside, X = .Parent.ID will give you ID of the - so you can't use it as reference in PAGES collection.

                       

                       

                      Unless by X = .Parent.ID you are trying to get ID of the parent page for the Object on that page, but still - if you know the page you are on - if you have reference to that page - you can use it directly in .Pages.Add().

                       

                      If I'm wrong - please show us more of your code.

                       

                      robin

                      www.adobescripts.com

                      • 88. Re: With CS5, some things have changed
                        Olav Kvern Level 1

                        Mike wrote: "With idDoc.Pages.Add(at:=idAfter, reference:=idDoc.Pages.ItemByID(X))"

                         

                        As far ask I know, using labeled parameters (e.g., "at:" or "reference:" in the above) in VBScript/VB method calls has never worked (or has never worked reliably) in InDesign scripting. I think I even wrote a note about it in the documentation somewhere, though I have no idea if it's still there. Just provide the parameters in order, omitting optional parameters that you don't need. In this case, something like this should work (untested, off the top of my head):

                         

                        Rem Given a page item "X" in a document "idDoc"...

                        idDoc.pages.add(idLocationOptions.idAfter, idDoc.pages.itemByID(X.parentPage.id))

                         

                        Thanks,

                         

                        Ole

                        • 89. Re: With CS5, some things have changed
                          Econometric Level 1

                          This is wonderful! Thank you! Everything is working now.

                          • 90. Re: With CS5, some things have changed
                            M F Walker

                            My admittedly old CD for InDesign 5 (Windows) is no longer readable. Where can I find a guide to scripting?

                            • 91. Re: With CS5, some things have changed
                              M F Walker Level 1

                              Problem solved!

                              • 92. Re: With CS5, some things have changed
                                Laubender Adobe Community Professional & MVP

                                Hi,

                                start your ExtendScript Toolkit app (ESTK) and look under "Help".

                                 

                                Don't know the exact paths under Windows, but for Mac OSX you'll find some PDFs about scripting CS5 here:

                                 

                                CS5 (version 7)

                                /Applications/Utilities/Adobe Utilities - CS5/ExtendScript Toolkit CS5/

                                ExtendScript Toolkit ReadMe.pdf

                                 

                                /Applications/Utilities/Adobe Utilities - CS5/ExtendScript Toolkit CS5/SDK/English/

                                Adobe Intro To Scripting.pdf

                                 

                                /Applications/Utilities/Adobe Utilities - CS5/ExtendScript Toolkit CS5/SDK/

                                JavaScript Tools Guide.pdf

                                 

                                And if you mean scripting of InDesign version 5 (CS3) your ExtendScript Toolkit 2 should lead the way.

                                 

                                If you do not have the ESTK available see here:

                                ExtendScript Toolkit Archives | Adobe Developer Connection

                                 

                                Indispensable resources of DOM documentation compiled by Jongware:

                                Indesign JavaScript Help

                                 

                                Regards,
                                Uwe

                                1 2 3 Previous Next