In C# or C++, when using Office (PowerPoint) APIs to convert a PPTX file to MP4, how can I preserve the animations contained in the PPTX?

hk chen 0 Reputation points
2025-07-24T09:54:49.4033333+00:00

I used the following code to convert a PPT file, but the resulting MP4 file did not retain the animations from the PPTX.

code:
using Microsoft.Office.Interop.PowerPoint;

using Application = Microsoft.Office.Interop.PowerPoint.Application;

using Presentation = Microsoft.Office.Interop.PowerPoint.Presentation;

using PowerPoint = Microsoft.Office.Interop.PowerPoint;

using Office = Microsoft.Office.Core;
Application pptApp = null;

Presentation presentation = null;

pptApp = new Application();

presentation=pptApp.Presentations.Open("e:\test.pptx",WithWindow:Microsoft.Office.Core.MsoTriState.msoFalse);

presentation.CreateVideo("e:\test.mp4",

  UseTimingsAndNarrations:true,

  DefaultSlideDuration: 5,

  VertResolution: 1080,

  FramesPerSecond: 30,

  Quality: 85);

while (presentation.CreateVideoStatus == PpMediaTaskStatus.ppMediaTaskStatusInProgress)

  Thread.Sleep(1000);
Microsoft 365 and Office | PowerPoint | Other | Windows
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Katerina-N 805 Reputation points Microsoft External Staff Moderator
    2025-07-24T20:53:24.9866667+00:00

    Hello hk chen ,

    Welcome to Microsoft Q&A!

    Thank you for your post. I understand that you are having issue when using Office (PowerPoint) APIs to convert a PPTX file to MP4. I truly understand how you feel. Let me assist you go through this situation.

    As your description, when you use:

    presentation.CreateVideo(…);
    

     ```

    PowerPoint will only “play” the animations if you have actual slide‐show timings recorded (or narrations). Otherwise, it simply uses the default slide duration you passed in and “snaps” each slide to a static image at that point.

    There is no magic flag in CreateVideo that says “just run all of my click animations in order and export them”—you must first give PowerPoint concrete timings for each animation. You can do that in two ways:

    Record slide timings – Manually via Slide Show → Record Slide Show (or Record Narration & Timings) in the UI – Programmatically by running through the slideshow and letting PowerPoint record the timestamps

    Programmatically set per‐slide durations based on the number (and/or length) of animations on each slide

    Once you have timings in your presentation, use:

      @"e:\test.mp4",
        UseTimingsAndNarrations: true,   // ← important!
        DefaultSlideDuration: 5,         // used only when a slide has *no* recorded timing
        VertResolution:       1080,
        FramesPerSecond:      30,
        Quality:              85);
    

      ```

    and your exported MP4 will include all of your animations.

    Option 1: Record timings by running the slide show

    using PowerPoint = Microsoft.Office.Interop.PowerPoint;
    using Office     = Microsoft.Office.Core;
    …
    var app = new PowerPoint.Application();
    app.Visible = Office.MsoTriState.msoTrue;
    // Open with window so animations actually fire
    var pres = app.Presentations.Open(
        @"e:\test.pptx",
        WithWindow: Office.MsoTriState.msoTrue);
    // Tell PowerPoint to use slide timings when advancing
    pres.SlideShowSettings.AdvanceMode = PowerPoint.PpSlideShowAdvanceMode.ppSlideShowUseSlideTimings;
    pres.SlideShowSettings.Run();
    

    That will force PowerPoint to walk through every click animation, record the timestamps, and then export them correctly.

    Option 2: Set a time per slide based on its animations

    If you know roughly how long each animation should take (or simply want “n seconds per animation plus a base duration”), you can set each slide’s transition time based on the count of its animation effects:

    using PowerPoint = Microsoft.Office.Interop.PowerPoint;
    using Office     = Microsoft.Office.Core;
    …
    var app = new PowerPoint.Application();
    var pres = app.Presentations.Open(
        @"e:\test.pptx",
        WithWindow: Office.MsoTriState.msoFalse);
    
    // For each slide, count the click‐on animations
    foreach (PowerPoint.Slide slide in pres.Slides)
    {
        int animCount = slide.TimeLine.MainSequence.Count;
        // Turn on “advance on time”
        slide.SlideShowTransition.AdvanceOnTime = Office.MsoTriState.msoTrue;
        // Set duration = 3 sec per animation + 3 sec base, for example
        slide.SlideShowTransition.AdvanceTime = animCount * 3 + 3;
    }
    
    // Now export using those timings
    pres.CreateVideo(
        @"e:\test.mp4",
        UseTimingsAndNarrations: true,
        DefaultSlideDuration: 5,
        VertResolution: 1080,
        FramesPerSecond: 30,
        Quality: 85);
    while (pres.CreateVideoStatus 
           == PowerPoint.PpMediaTaskStatus.ppMediaTaskStatusInProgress)
        System.Threading.Thread.Sleep(1000);
    

    This approach is adapted from Onur Önder’s VBA/C# timing script, which shows how to set AdvanceTime based on the animation count.

    Here is why simply calling CreateVideo with your original code didn’t work:

    presentation.CreateVideo(
      @"e:\test.mp4",
      UseTimingsAndNarrations:true,
      DefaultSlideDuration:5,
      VertResolution:1080,
      FramesPerSecond:30,
      Quality:85);
    

    UseTimingsAndNarrations:true only uses recorded timings/narrations – If no timings exist, PowerPoint falls back to DefaultSlideDuration for every slide and never fires individual animations

    By first creating real slide timings—either by recording the show or programmatically setting them—you give PowerPoint the data it needs to replay your click effects in the exported MP4.

    I hope this will help with your situation. Please feel free to let me know if you have any further update.

    Best Regards,

    Katerina- MSFT | Microsoft Q&A Support Specialist


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment”.   

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. 

    0 comments No comments

  2. Katerina-N 805 Reputation points Microsoft External Staff Moderator
    2025-07-26T21:13:37.0733333+00:00

    Hello hk chen,

    Thank you for your post.

    I haven't received any further update from you yet. If there is anything more that I could do for you or if anything is unclear that I can assist you with. Please do not hesitate to let me know.

    Best Regards,

    Katerina- MSFT | Microsoft Q&A Support Specialist


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment”.   

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. 


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.