Create Word
Creates a new Word document at the specified path.
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
- Path - File path where the Word document will be created. Must include the full path with .docx extension (e.g.,
/home/user/documents/report.docxorC:\Documents\report.docx).
Output
- Out File Descriptor - Unique identifier for the created document. This file descriptor is used by other Word nodes to reference the document. Default variable name is
word_fd.
Options
- Overwrite - Determines whether to overwrite an existing file at the specified path. Default is false.
How It Works
The Create Word node creates a new blank Word document and saves it to the specified path. When executed, the node:
- Validates the provided file path
- Checks if a file already exists at the path (raises error if exists and Overwrite is disabled)
- Creates a new blank Word document in memory
- Generates a unique file descriptor for the document
- Saves the document to the specified path
- Returns the file descriptor for use with other Word nodes
Requirements
- Valid file path with .docx extension
- Write permissions for the target directory
- Parent directory must exist (or will be created automatically by some operating systems)
Error Handling
The node will return specific errors in the following cases:
- Empty file path
- File already exists at the path and Overwrite option is disabled
- Invalid file path format
- Insufficient permissions to write to the specified location
- Disk space issues
Usage Example
Scenario: Create a new Word document for a monthly report
// Set the output path for the report
$local.reportPath = "/home/user/reports/monthly_report_2025.docx";
Configuration:
- Path:
{{$local.reportPath}} - Overwrite:
true
Output:
- The node creates a new Word document and returns a file descriptor in
{{$message.word_fd}} - This file descriptor is then used with Add Text, Add Table, or other Word nodes
Usage Notes
- The file is created and saved immediately when the node executes
- The file descriptor remains valid throughout the flow execution
- You can create multiple Word documents in the same flow by using different paths
- Even though the file is created, you should still use the Save node at the end to ensure all changes are persisted
- If the directory path doesn't exist, the node may fail - ensure parent directories are created first
- Use forward slashes (/) or escaped backslashes (\\) in file paths for cross-platform compatibility
Tips for Effective Use
- Use Variables for Paths: Store file paths in variables to make flows more maintainable
- Include Timestamps: Add dates or timestamps to filenames to avoid conflicts (e.g.,
report_{{$date.now}}.docx) - Test Paths First: Verify directory existence before creating documents
- Handle Overwrite Carefully: Enable Overwrite only when you're certain existing files should be replaced
- Combine with Save Node: Always use the Save node after making changes to ensure data persistence
Common Errors and Solutions
| Error | Cause | Solution |
|---|---|---|
| "Path cannot be empty" | No file path provided | Provide a valid file path in the Path input |
| "File already exists and overwrite is disabled" | File exists at the specified path | Enable the Overwrite option or use a different file path |
| "Failed to create Word document" | Permission issues or invalid path | Check file permissions and verify the path is valid |
| "ErrRuntime" | Unexpected system error | Check disk space, permissions, and path validity |