> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# On Open Document

> On Open Document runs when a document opens in the FlexiCapture document editor, after all editor windows are created; closing it from the script fails.

## When it is launched

The script is launched upon opening a document in the document editor (when opening a new document window or going to a new document).

When the script is launched, all windows inside the document editor are already created.

## Parameters

| **Name** | **Type**                                                                 | **Access** | **Description**     |
| -------- | ------------------------------------------------------------------------ | ---------- | ------------------- |
| Context  | [IDocumentEditor](/flexi-capture/appendix/scripts-shell/idocumenteditor) | Read/write | The document editor |

<Note>
  Closing the document from this script is not allowed. Using the command **DocumentEditor.TaskWindow\.CloseEditorWindow();** will cause the error message:
</Note>

```
"System.Runtime.InteropServices.COMException (0x80004005): Document editor cannot be closed."
```
