A nasty bug "happened" in CS5. The idea is that you should be able to access labelled items using pageItems.itemByName (myName), but that doesn't work for labels. One way out is to change all labels to names:
myPageItem.name = myPageItem.label
You can then see the item's name in the links panel. The trouble with this, though, is that when you then do pageItems.itemByName (myName), you get only one page item with that name, even if there are several with the same name.
You'll have to use your own function to collect page items with a certain label, e.g.
function find_labels (there, myLabel)
var array = ;
var p_items = there.pageItems.everyItem.getElements();
// or var p_items = there.pageItems;
for (var i = 0; i < p_items.length; i++)
if (p_items[i].label == myLabel)
This is a monumental PITA as it means you have to adaop all your scripts (versioning doesn't work) and it slows down your scripts.
Thanks you a lot Peter for your answer !
Why go easy when we can do so difficult !!!
Your function will be very useful to me and probably many other folks.
BTW, I found that Harbs post that tells all :
Ah, yes, that thread says it all and much better. Brain's on holiday.