# How to Add Animations to PowerPoint Shapes with Emphasis and Exit Effects Using OfficeCLI

> Easily add emphasis and exit animations to PowerPoint shapes programmatically using OfficeCLI. Automate your presentations with path-based DOM commands and generate XML efficiently.

- Repository: [OfficeAI/OfficeCLI](https://github.com/iofficeai/OfficeCLI)
- Tags: how-to-guide
- Published: 2026-08-09

---

**OfficeCLI enables programmatic attachment of 15 emphasis and 16 exit animation presets to PowerPoint shapes via path-based DOM commands, generating `<p:timing>` XML through [`PowerPointHandler.Set.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PowerPointHandler.Set.cs) and batch processing in [`PptxBatchEmitter.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PptxBatchEmitter.cs).**

OfficeCLI from the iOfficeAI repository treats every PowerPoint element as a node in a path-addressable DOM, allowing developers to script sophisticated animation sequences without launching the GUI. By targeting specific paths such as `/slide[N]/shape[M]/animation[K]`, you can attach **emphasis effects** like `EmphasisFade` or **exit effects** like `ExitSpin` directly from automated pipelines or AI agent workflows.

## Understanding the Animation DOM Model

OfficeCLI stores animations as child nodes of shapes or charts using a strict hierarchical path syntax. When you reference `/slide[1]/shape[2]/animation[1]`, you are targeting the first animation attached to the second shape on the first slide.

According to the source code in [`src/officecli/Handlers/Pptx/PowerPointHandler.Set.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/Handlers/Pptx/PowerPointHandler.Set.cs) at line 283, the CLI matches paths using the pattern:

```

/slide[<num>]/(shape|chart)[<num>]/animation[<num>]

```

This path-based approach means animations are **first-class objects** within the presentation structure. Internally, when you supply an `animation` property, the CLI parses the value, validates it against built-in preset names, and generates the appropriate `<p:timing>` XML elements as documented in the README at line 183.

## Built-in Animation Presets

OfficeCLI ships with 31 predefined animation effects that map directly to PowerPoint's native timing engine:

- **15 emphasis effects** (e.g., `EmphasisFade`, `EmphasisZoom`, `EmphasisWipe`)
- **16 exit effects** (e.g., `ExitSpin`, `ExitDisappear`, `ExitFlyOut`)

To view the complete list of available presets for your version, run:

```bash
officecli help pptx set shape

```

The preset names are case-insensitive, and the CLI resolves them to the correct PowerPoint animation identifiers during the batch emission phase handled by [`src/officecli/Handlers/Pptx/PptxBatchEmitter.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/Handlers/Pptx/PptxBatchEmitter.cs) at line 1011.

## Core Operations for Animation Management

You can perform five primary operations on shape animations using the `add`, `set`, `remove`, and `query` commands.

### Create a Shape with an Attached Animation

When adding a new shape, include the `animation` property to bind the effect during creation. The CLI captures this entry in the shape’s format bag and emits it as an `add animation` batch item.

```bash
officecli add deck.pptx '/slide[1]' --type shape \
    --prop text="Revenue ↑ 30%" \
    --prop x=2cm --prop y=4cm \
    --prop size=24 \
    --prop animation=EmphasisFade

```

### Append Animations to Existing Shapes

To attach a second or third animation to a shape that already exists, target the shape path directly and specify `--type animation`:

```bash
officecli add deck.pptx '/slide[1]/shape[2]' --type animation \
    --prop animation=ExitSpin

```

### Update or Replace Animations

Modify an existing animation by targeting its specific index path with the `set` command. This overwrites the animation type and any associated properties at that node.

```bash
officecli set deck.pptx '/slide[1]/shape[2]/animation[1]' \
    --prop animation=EmphasisZoom

```

### Remove Unwanted Animations

Delete a specific animation node entirely using the `remove` command:

```bash
officecli remove deck.pptx '/slide[1]/shape[2]/animation[1]'

```

### Query Animation Metadata

Retrieve JSON describing every animation attached to slide elements using the `query` command with a filter:

```bash
officecli query deck.pptx "/slide[1]" --json

```

## Configuring Advanced Animation Properties

Beyond preset selection, OfficeCLI exposes fine-grained control over timing and behavior through sub-properties. You can specify **trigger** conditions, **delay** intervals, **duration**, **repeat** counts, and **auto-reverse** settings.

Valid time values accept flexible formats: `0.5s`, `500ms`, or plain seconds (`0.5`).

```bash
officecli set deck.pptx '/slide[1]/shape[2]/animation[1]' \
    --prop animation=EmphasisWipe \
    --prop trigger=after \
    --prop delay=0.5s \
    --prop duration=2s \
    --prop repeat=2 \
    --prop autoReverse=true

```

## Previewing Changes in Real Time

Because OfficeCLI operates headlessly, you can validate animation effects immediately without opening PowerPoint. Generate a static HTML preview or launch a live reload server.

To create a one-time HTML render:

```bash
officecli view deck.pptx html -o deck.html

```

To start a live preview server that updates as you modify animations (accessible at `http://localhost:26315` by default):

```bash
officecli watch deck.pptx

```

This workflow allows AI agents and CI pipelines to validate animation timing in a render loop before finalizing the presentation.

## Summary

- **Path-based targeting**: Animations reside at `/slide[N]/shape[M]/animation[K]` and are managed as child nodes of shapes or charts.
- **31 built-in presets**: OfficeCLI supports 15 emphasis and 16 exit effects via the `animation` property, resolved in [`PowerPointHandler.Set.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PowerPointHandler.Set.cs).
- **Batch emission**: Animation commands are processed into `<p:timing>` XML by [`PptxBatchEmitter.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PptxBatchEmitter.cs) during the commit phase.
- **CRUD operations**: Use `add` (with `--type shape` or `--type animation`), `set`, `remove`, and `query` to manage animation lifecycles.
- **Fine-grained control**: Adjust timing with `delay`, `duration`, `repeat`, `trigger`, and `autoReverse` using flexible time formats.
- **Headless validation**: Preview results instantly using `officecli view` or `officecli watch` without launching the PowerPoint desktop application.

## Frequently Asked Questions

### What source file handles animation path parsing in OfficeCLI?

The path matching and validation logic for animation nodes is implemented in [`src/officecli/Handlers/Pptx/PowerPointHandler.Set.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/Handlers/Pptx/PowerPointHandler.Set.cs) at line 283. This file parses the `/slide[<num>]/(shape|chart)[<num>]/animation[<num>]` pattern and updates the shape’s internal format bag accordingly.

### How many built-in emphasis and exit animation presets does OfficeCLI support?

OfficeCLI provides 31 built-in presets: 15 emphasis effects such as `EmphasisFade` and `EmphasisWipe`, plus 16 exit effects including `ExitSpin` and `ExitDisappear`. These presets are documented in the README at line 183 and map directly to PowerPoint’s native animation engine.

### Can I attach multiple animations to a single PowerPoint shape using OfficeCLI?

Yes, you can chain multiple animations by repeatedly using the `add` command with `--type animation` targeting the same shape path (e.g., `/slide[1]/shape[2]`). Each invocation creates a new animation node at the next available index (`animation[1]`, `animation[2]`, etc.), which you can later modify or remove individually.

### What time formats does OfficeCLI accept for animation delays and durations?

OfficeCLI accepts three time formats for the `delay` and `duration` properties: explicit seconds with the `s` suffix (e.g., `2s`), milliseconds with the `ms` suffix (e.g., `500ms`), or plain decimal numbers representing seconds (e.g., `0.5`). All formats are normalized internally before generating the presentation XML.