How to Create Morph Transitions and Other Slide Transitions in PowerPoint with OfficeCLI
Use the officecli set command with the --prop transition flag to apply any PowerPoint transition type, including morph effects, by specifying transition tokens like morph-byword-slow or fade-fast-1500.
OfficeCLI manipulates PowerPoint files through the OpenXML SDK, offering a declarative, scriptable interface for slide animations. To create morph transitions and other slide transitions in PowerPoint with OfficeCLI, you pass structured property strings that the CLI converts into strongly-typed OpenXML transition elements.
How OfficeCLI Processes Transition Commands
Command Parsing in PowerPointHandler.Set.Slide.cs
The entry point for transition commands is the SetSlideByPath method in src/officecli/Handlers/Pptx/PowerPointHandler.Set.Slide.cs. When you execute a set command targeting a specific slide path (e.g., /slide[2]), this method matches the transition key and forwards the value to ApplyTransition and optionally ApplyTransitionSpeed.
Building Transition Elements in PowerPointHandler.Animations.cs
The ApplyTransition method in src/officecli/Handlers/Pptx/PowerPointHandler.Animations.cs handles the heavy lifting of constructing the actual XML. It splits the supplied string—such as morph-byword-slow-1500—into tokens representing the type, optional direction, speed, duration, and special modifiers.
For classic transitions like fade, cut, or wipe, the method instantiates strongly-typed OpenXML subclasses such as new FadeTransition(), setting properties like ThroughBlack, Direction, Speed, and Duration based on parsed tokens.
For Morph transitions specifically, the handler calls AutoPrefixMorphNames, which automatically prepends !! to every shape name on the slide. This enables the OOXML "shape-by-name" binding required for PowerPoint's morph animation engine.
Helper Utilities in PowerPointHandler.Helpers.Transition.cs
The FindOrCreateTransition method in src/officecli/Handlers/Pptx/PowerPointHandler.Helpers.Transition.cs guarantees that a <p:transition> element exists before properties are set. It handles edge cases where slides contain unknown-element transitions by creating new transition nodes when necessary.
Applying Standard Slide Transitions
Standard transitions use a token syntax combining the transition type with optional speed and duration modifiers separated by hyphens.
# Simple fade with default speed
officecli set deck.pptx /slide[2] --prop transition=fade
# Cut transition with fast speed
officecli set deck.pptx /slide[3] --prop transition=cut-fast
# Wheel transition with 8 spokes and 1.5 second duration
officecli set deck.pptx /slide[4] --prop transition=wheel-8-1500
# Modern Office 2010 transition with reverse direction
officecli set deck.pptx /slide[5] --prop transition=peelOff-out
The CLI parses these strings in a single pass. Specifying transition=fade-fast sets Speed = Fast, while transition=fade-1500 sets Duration = "1500" milliseconds. Combined shortcuts like transition=morph-slow-2000 set both properties simultaneously.
Creating Morph Transitions
Morph transitions require specific setup because they animate between consecutive slides based on matching shape names.
Basic Morph Setup
To create a morph transition, apply the property to both the source and target slides:
# Apply morph to slide 2 (source)
officecli set deck.pptx /slide[2] --prop transition=morph
# Apply morph to slide 3 (target) - required for the effect to work
officecli set deck.pptx /slide[3] --prop transition=morph
How Morph Works Internally
When you set transition=morph, OfficeCLI automatically invokes AutoPrefixMorphNames in PowerPointHandler.Animations.cs. This method prepends !! to every shape name on the slide, enabling the OOXML shape-by-name binding that PowerPoint requires for morph animation. Selectors using @name= still resolve the original name, though the stored name includes the prefix.
Morph Variants
OfficeCLI supports word-level and character-level morph animations through specific modifiers:
# Morph by word with slow speed
officecli set deck.pptx /slide[6] --prop transition=morph-byword-slow
# Morph by character with 2 second duration
officecli set deck.pptx /slide[7] --prop transition=morph-bychar-2000
These variants add the appropriate Morph-type attributes (byWord, byChar) to the transition element.
Supported Transition Types and Modifiers
The ApplyTransition method in PowerPointHandler.Animations.cs enumerates every built-in transition the CLI supports.
Transition Types
Supported types include classic transitions (fade, cut, wipe, push, wheel, circle, diamond) and modern Office 2010 transitions (peelOff, airplane, prism, vortex, shred, switch).
Modifiers
- Speed:
slow,fast(maps to OpenXMLSpeedenum) - Duration: Numeric value in milliseconds (e.g.,
1500,2000) - Direction:
in,out,up,down,left,right(context-dependent on transition type) - Special parameters: For wheel transitions, specify spoke count (e.g.,
wheel-8)
To clear any transition, set the value to none or false, which removes the entire <p:transition> element including alternate-content wrappers for Morph.
# Clear transition from slide 4
officecli set deck.pptx /slide[4] --prop transition=none
Summary
- Use
officecli set deck.pptx /slide[N] --prop transition=<type>to apply any PowerPoint transition from the command line. - The
PowerPointHandler.Set.Slide.csfile routes transition commands toApplyTransitioninPowerPointHandler.Animations.cs. - Morph transitions require the property on both consecutive slides and automatically trigger
AutoPrefixMorphNamesto prepend!!to shape names. - Combine transition types with speed (
fast,slow), duration (milliseconds), and direction modifiers using hyphen-separated tokens. - Use
transition=noneto remove transition elements entirely via the helper methods inPowerPointHandler.Helpers.Transition.cs.
Frequently Asked Questions
How do I remove a transition from a slide?
Set the transition property to none or false. This triggers the removal of the entire <p:transition> element, including any alternate-content wrappers specific to Morph transitions. The FindOrCreateTransition helper in PowerPointHandler.Helpers.Transition.cs handles the deletion logic.
Why isn't my morph transition working?
Morph requires the transition property on both consecutive slides. Ensure you run officecli set with transition=morph on both the source slide and the target slide. OfficeCLI automatically prefixes shape names with !! to enable OOXML binding, but both slides must have the transition flag set for PowerPoint to render the animation.
Can I combine multiple transition modifiers?
Yes. OfficeCLI parses transition tokens in a single pass, allowing combinations like transition=fade-fast-1500 or transition=morph-byword-slow. The ApplyTransition method extracts speed, duration, direction, and special modifiers (like byWord or spoke counts) from the hyphen-delimited string.
Where does OfficeCLI store transition settings?
OfficeCLI writes transition settings directly into the PowerPoint OpenXML structure via the OpenXML SDK. The ApplyTransition method in PowerPointHandler.Animations.cs creates strongly-typed transition elements (such as FadeTransition or MorphTransition) and inserts them into the slide's <p:transition> node, which PowerPoint reads when presenting.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →