Skip navigation

With CS5, some things have changed

Oct 3, 2010 1:50 AM

  Latest reply: Econometric, Oct 13, 2011 7:13 AM
Branched to a new discussion.
Replies 1 2 3 Previous Next
  • Currently Being Moderated
    Sep 9, 2011 1:57 PM   in reply to Harbs.

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 27, 2011 12:51 PM   in reply to Harbs.

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 27, 2011 2:45 PM   in reply to Econometric

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 28, 2011 9:04 AM   in reply to Robert-Tkaczyk

    Using the number worked perfectly. Thank you!!

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 28, 2011 3:43 PM   in reply to Harbs.

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

     

    Thank you,

    Mike

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 28, 2011 3:49 PM   in reply to Econometric

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 4, 2011 8:04 AM   in reply to Harbs.

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 4, 2011 9:17 AM   in reply to Econometric
    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

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 4, 2011 11:32 AM   in reply to Robert-Tkaczyk

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 13, 2011 7:13 AM   in reply to Robert-Tkaczyk

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

     
    |
    Mark as:
1 2 3 Previous Next
Actions

More Like This

  • Retrieving data ...

Bookmarked By (1)