How can I add an existing video in a slide (PPT) using MATLAB?

9 ビュー (過去 30 日間)
Fabio Ambrosio
Fabio Ambrosio 2021 年 5 月 11 日
編集済み: Wei Sun 2023 年 2 月 5 日
I need to create reports in PowerPoint (PPT) using Matlab.
I have a video in AVI format and I would like to add it in the report (PPT) created.
I can see that it is possible to add pictures with limited formats, such as .bmp .emf .eps .gif .jpeg .jpg .png .tif.
However, I cant find anything about to add video format, such as mp4, avi, wmv etc.
Is it possible to do this using Matlab? Could you help me with any solution?
Tks.

回答 (1 件)

Rahul Singhal
Rahul Singhal 2021 年 5 月 19 日
Hi Fabio,
Currently, the PPT API doesn't support programmatically adding a video file to a slide.
This is something the development team is aware of and is considering to support in an upcoming release.
-Rahul
  4 件のコメント
Fabio Ambrosio
Fabio Ambrosio 2021 年 11 月 16 日
編集済み: Fabio Ambrosio 2021 年 11 月 16 日
Yes. You need to use the actxserver() and AddMediaObject2 method in your MATLAB code.
Below is an example to add a video in AVI format on the second page of the slide:
% Create an ActiveX object
ppt = actxserver('powerpoint.application');
% Open a specific presentation
ppt.Presentations.Open('C:\Users\PATH\test\my_presentation.pptx');
% Select a slide layout
layout = ppt.ActivePresentation.SlideMaster.CustomLayouts.Item(6);
% Add a new slide on page 2 with selected layout
page = 2;
ppt.ActivePresentation.Slides.AddSlide(page, layout);
% Select a slide page
slides = ppt.ActivePresentation.Slides;
slidePage = slides.Item(page);
slidePage.Select;
videoPath = 'C:\Users\PATH\my_video.avi';
% Add video with AVI format in a specific position
video = ppt.ActiveWindow.Selection.SlideRange(1).Shapes.AddMediaObject2(videoPath, 0, -1, 160, 75,500,210);
%save presentation
ppt.ActivePresentation.Save;
I hope this help you.
Wei Sun
Wei Sun 2023 年 2 月 5 日
編集済み: Wei Sun 2023 年 2 月 5 日
Any code playing that video automaticlly when entering that slide? I tried using the following code. But it is not working.
set(video.AnimationSettings.PlaySettings,'PlayOnEntry','msoTrue');
Thank you!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB Report Generator についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by