Which version of ID?
No need to use name, label and contents all together - one of them is good enough.
Try to notice anything about ommited textFrames (their location, page, layer, contents, anchored status..., any)
Your code need both cleaning and correction, however more info can be helpful.
This is just a guess but try running your loop in reverse:
for (k=myFinds.length-1; k >= 0; k--)
Sometimes a loop will change the array it's working on and the result is usually something like "some items get skipped."
I wonder why one loop to insert labels and a second loop to replace them. Why not find 'em and fix 'em at the same time.
Also, is it your intent to move only the last inserted asset? The move line seems to be outside the second loop.
Its ID 4.
Tried to clean up the code but to no success.
I'm kinda new at javscripting and I can't seem
to get it to work if I change anything. I dunno
why it won't work with just labels, name or
contents but it won't, atleast not for me
Reversed the loop, same thing happened.
The move thing works for all replaced assets.
first off, app.activeDocument.textFrames seems to miss any text frames that are part of a group. If that's a factor in your document, start with myDoc.allPageItems and test the .constructor.name
What I was suggesting might look like this:
for (i=0; i<myDocItems.length; i++)
if (myDocItems[i].contents == "SKINN")
myDocItems[i].move (undefined, ["-6 pt", "-11 pt"]);
Just one loop: If the contents of one text frame match "SKINN", it is replaced by the library asset and the text frame is moved. You could assign a label at the same time, if you really need one.
Your original code, seems to me might suffer from a number of problems:
1) You set the variable myObject to text frames labeled "SKINN" before you actually apply the label. Maybe that works, it just seems counter-intuitive.
2) Your second loop is based on the array myFinds, but you use the index from myFinds to grab an object in the array app.selection. Again, it's possible that those indexes are the same, but I would want to do a lot of testing before I relied on it.