# Can I open a Photoshop file with UXP?

**URL:** <https://forums.creativeclouddeveloper.com/t/can-i-open-a-photoshop-file-with-uxp/2120>\
**Category:** UXP Plugin API\
**Created:** [October 28, 2020, 12:16am UTC](https://forums.creativeclouddeveloper.com/t/can-i-open-a-photoshop-file-with-uxp/2120 "2020-10-28T00:16:11Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [October 10, 2022, 11:42am UTC](https://forums.creativeclouddeveloper.com/t/can-i-open-a-photoshop-file-with-uxp/2120/15 "2022-10-10T11:42:59Z")

</div>

To use executeAsModal you need to first import it from `photoshop` and then you can pass it a function as its parameter to execute that code with Photoshop in a modal state.

```auto
// Imports
const { app, core } = require("photoshop");
const fs = require("uxp").storage.localFileSystem;

// Open document helper function
async function openDocument() {
  const pluginFolder = await fs.getPluginFolder();
  const theTemplate = await pluginFolder.getEntry("yourFile.psd");

  // The document is opened 
  await app.open(theTemplate);
}

// Main function - is async so that await can be used within
async function main() {
  // Passing openDocument function to executeAsModal to open file 
  await core.executeAsModal(openDocument);
}

// Run main function from inside try/catch for error handling
try {
  // Don't need to await because a) nothing to run after it and b) you can't anyway because top-level await is not allowed
  main();
} catch (error) {
  console.error(error);
  console.trace(error);
}

```

EDIT: Code edited to remove error inducing return statements and incorrect imports.

---

_[View the full topic](https://forums.creativeclouddeveloper.com/t/can-i-open-a-photoshop-file-with-uxp/2120)._
