Indesign: Copy item via script label

Hi

I’m looking to copy an item to the pasteboard by selecting from a document via its script label.

I have the below but it’s not correct.

If it helps, there will only be one item per name on the page.

thanks

Shane

tell application "Adobe InDesign 2022"
	tell active document
		
		copy (every page item whose label is "NAME")
		
	end tell
	
end tell



Hi. Copy only works on selections, and your scope would need to be narrowed, unless there’s only one matching label per document, as selections don’t cross pages. I think this example may work to answer your question, but your version has some differences from mine and the question is probably not the right one; there is rarely ever a compelling reason to use a selection for anything other than testing, as they are inefficient GUI processes.


tell application "Adobe InDesign 2022"
	select document 1's (page 1's page items whose label is "NAME")'s item 1
	copy
end tell

Thanks Marc

Yes, that works great.

I have a single page with 10 items with individual tags, I need them in the pasteboard as I’m doing a GREP search, replacing with the contents of the pasteboard – in this case an anchored object.