Set a new activeDocument by document name

I’ve been reading the information on the activeDocument API:

The code examples are the same for “get” and “set”, though it looks like one returns a promise (get) and the other doesn’t (set). I’m not sure how Photoshop knows the difference, though.

Anyway, I’m trying to programmatically choose a new activeDocument, probably using the documents name. I’m not sure how to do it with this “activeDocument” API. I tried Alchemist also, but it just provides a new document relative to the original document via an “offset” value, and that’s not very practical since this offset will vary by how the user has their open documents arranged. I could iterate through all the app.documents, but still not sure how to make the one I want the activeDocument once I find it. This doesn’t sound like it should be so hard, but currently has me stumped. :worried:

Use ID in reference instead of offset.

“_id” works to select the document.

Thank you.