Skip to main content

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.docx or C:\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:

  1. Validates the provided file path
  2. Checks if a file already exists at the path (raises error if exists and Overwrite is disabled)
  3. Creates a new blank Word document in memory
  4. Generates a unique file descriptor for the document
  5. Saves the document to the specified path
  6. 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

  1. Use Variables for Paths: Store file paths in variables to make flows more maintainable
  2. Include Timestamps: Add dates or timestamps to filenames to avoid conflicts (e.g., report_{{$date.now}}.docx)
  3. Test Paths First: Verify directory existence before creating documents
  4. Handle Overwrite Carefully: Enable Overwrite only when you're certain existing files should be replaced
  5. Combine with Save Node: Always use the Save node after making changes to ensure data persistence

Common Errors and Solutions

ErrorCauseSolution
"Path cannot be empty"No file path providedProvide a valid file path in the Path input
"File already exists and overwrite is disabled"File exists at the specified pathEnable the Overwrite option or use a different file path
"Failed to create Word document"Permission issues or invalid pathCheck file permissions and verify the path is valid
"ErrRuntime"Unexpected system errorCheck disk space, permissions, and path validity