Open Word
Opens an existing Word document or creates a new blank document.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing the node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- File Path - Path to the Word document to open. Leave empty to create a new blank document in memory. When provided, must be a valid path to an existing .docx file.
Output
- Out File Descriptor - Unique identifier for the opened or created document. This file descriptor is used by other Word nodes to reference the document. Default variable name is
word_fd.
How It Works
The Open Word node is flexible and can work in two modes:
Mode 1: Open Existing Document
- Validates the provided file path
- Checks if the file exists at the specified location
- Opens the Word document
- Generates a unique file descriptor
- Returns the file descriptor for use with other Word nodes
Mode 2: Create New Document (when path is empty)
- Creates a new blank Word document in memory
- Generates a unique file descriptor
- Returns the file descriptor
- Note: Document is not saved until you use the Save node
Requirements
- When opening existing file: Valid file path to an existing .docx file
- When opening existing file: Read permissions for the file
- When creating new: No requirements
Error Handling
The node will return specific errors in the following cases:
- File not found at the specified path
- Invalid file path format
- Insufficient permissions to read the file
- Corrupted or invalid Word document
- File is locked by another application
Usage Examples
Example 1: Open Existing Document
Scenario: Open an existing Word template to fill with data
// Set the path to the template
$local.templatePath = "/home/user/templates/invoice_template.docx";
Configuration:
- File Path:
{{$local.templatePath}}
Output:
- Opens the template and returns a file descriptor in
{{$message.word_fd}} - Use Replace Text or other nodes to modify the template
Example 2: Create New Document in Memory
Scenario: Create a new document without specifying a path initially
Configuration:
- File Path: (leave empty)
Output:
- Creates a blank document in memory with file descriptor in
{{$message.word_fd}} - Add content with Add Text, Add Table, etc.
- Save to a specific path using the Save node
Usage Notes
- This is typically the first node in a Word automation flow
- The file descriptor is essential for all subsequent Word operations
- Opening a document doesn't lock it - other applications can still access it
- Documents opened but not saved will lose any modifications
- Always use the Save node to persist changes to existing documents
- When creating a new document in memory, you must specify a path in the Save node
Tips for Effective Use
- Template Workflows: Use this node to open pre-formatted Word templates
- Variable Paths: Store file paths in variables for dynamic document processing
- Error Handling: Always check if files exist before attempting to open them
- Multiple Documents: You can open multiple documents in the same flow by storing different file descriptors
- Memory Documents: Use empty path for temporary documents that may not need saving
Best Practices
- Verify File Existence: Use file system nodes to check if a file exists before opening
- Handle Permissions: Ensure the robot has read permissions for the target file
- Close Properly: Always save or explicitly handle documents at the end of your flow
- Use Templates: Store frequently-used formats as templates and open them with this node
- Path Format: Use absolute paths for reliability, or relative paths from the project directory
Common Errors and Solutions
| Error | Cause | Solution |
|---|---|---|
| "File not found at [path]" | File doesn't exist at the specified location | Verify the file path is correct and the file exists |
| "Failed to open Word document" | Corrupted file or permission issues | Check file integrity and permissions |
| "ErrNotFound" | Invalid or empty path when trying to open | Provide a valid file path or leave empty to create new |
| "ErrRuntime" | Unexpected system error | Check file isn't locked by another application |
Difference from Create Word Node
| Feature | Open Word | Create Word |
|---|---|---|
| Can open existing files | Yes | No |
| Can create in memory | Yes | No |
| Immediately saves to disk | No | Yes |
| Requires file path | Optional | Required |
| Overwrites existing files | No | Yes (with option) |
Use Open Word when you need flexibility, and Create Word when you want to immediately create a file on disk.