# Set a new activeDocument by document name

**URL:** <https://forums.creativeclouddeveloper.com/t/set-a-new-activedocument-by-document-name/2820>\
**Category:** Photoshop\
**Created:** [April 15, 2021, 7:33pm UTC](https://forums.creativeclouddeveloper.com/t/set-a-new-activedocument-by-document-name/2820 "2021-04-15T19:33:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnthonyK](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@AnthonyK](https://forums.creativeclouddeveloper.com/u/AnthonyK)\
**Post date:** [April 15, 2021, 7:33pm UTC](https://forums.creativeclouddeveloper.com/t/set-a-new-activedocument-by-document-name/2820/1 "2021-04-15T19:33:18Z")

</div>

I’ve been reading the information on the activeDocument API: [https://www.adobe.io/photoshop/uxp/ps\_reference/classes/photoshop/#activedocument](https://www.adobe.io/photoshop/uxp/ps_reference/classes/photoshop/#activedocument)

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. 😟

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [April 15, 2021, 7:37pm UTC](https://forums.creativeclouddeveloper.com/t/set-a-new-activedocument-by-document-name/2820/2 "2021-04-15T19:37:47Z")

</div>

Use ID in reference instead of offset.

---

<div class="post-metadata">

**Author:** ![AnthonyK](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@AnthonyK](https://forums.creativeclouddeveloper.com/u/AnthonyK)\
**Post date:** [April 15, 2021, 9:40pm UTC](https://forums.creativeclouddeveloper.com/t/set-a-new-activedocument-by-document-name/2820/3 "2021-04-15T21:40:38Z")

</div>

“\_id” works to select the document.

Thank you.
