embed_cdxml_in_office
Convert CDXML files into double-clickable, editable ChemDraw OLE objects within PowerPoint or Word documents.
Instructions
Embed a CDXML file as an editable ChemDraw OLE object in PPTX or DOCX.
Converts CDXML → CDX + EMF preview via ChemDraw COM, builds a CFB OLE compound file, and injects it into a PPTX slide or DOCX paragraph as a double-clickable, editable ChemDraw object.
Requires: ChemDraw COM (Windows, ChemDraw 16+), python-pptx or python-docx. ChemDraw must be installed and closed before calling this tool.
The output format (.pptx or .docx) is detected from office_path extension. If office_path does not exist, a new file is created.
Args: cdxml_path: Path to the CDXML file to embed. office_path: Path to the target .pptx or .docx file. Created if it does not exist. output_path: Output file path. If not given, writes to office_path (modifies in place via temp file).
Returns: Dict with keys: ok, input_cdxml, output (absolute path to written Office file), format ("pptx" or "docx"), num_objects_embedded. Returns {ok: False, error: "..."} if embedding fails.
Safety override: Create a new validated PPTX or DOCX and reject all existing targets.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cdxml_path | Yes | ||
| office_path | Yes | ||
| output_path | No |