MATLAB を使用して MS PowerPoint のスライドを作成するにはどうすればよいですか?
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Windows 7 と MATLAB 7.13 (R2011b) を使用しています。MATLAB と ACTXSERVER を使用して Microsoft PowerPoint 2007 にスライドを追加する方法を教えてください。
Réponse acceptée
MathWorks Support Team
le 22 Avr 2013
Office 2007 の Microsoft API は Office 2003 と異なります。MATLAB から PowerPoint 2007 で新規プレゼンテーションを使用してスライドを追加するには、以下のようなコードを実行します。(既存の PPT に対して処理を行う場合には、コメント化している箇所をご参照ください。)
% ActiveX オブジェクトを作成
ppt = actxserver('powerpoint.application');
ppt.Visible = 1;
% ファイルのフルパスを指定し、既存のプレゼンテーションをオープン
%ppt.Presentations.Open('C:\MyFolder\test.ppt');
% 新しいプレゼンテーションを作成
ppt.Presentations.Add()
% プレゼンテーションに空白スライドを追加
layout = ppt.ActivePresentation.SlideMaster.CustomLayouts.Item(1);
ppt.ActivePresentation.Slides.AddSlide(1, layout);
% カスタムスライドを追加し、画像をそのスライドに追加
layout = ppt.ActiveWindow.Selection.SlideRange(1).CustomLayout;
slides = ppt.ActivePresentation.Slides;
newSlide = slides.AddSlide(1,layout);
% 画像ファイルのフルパスを指定して画像を追加
pic = ...
ppt.ActiveWindow.Selection.SlideRange(1).Shapes.AddPicture( ...
fullfile(matlabroot,'toolbox','images','imdemos','football.jpg'), ...
'msoFalse','msoTrue',100,20,500,500);
% 他の画像を追加
pic2 = ...
ppt.ActiveWindow.Selection.SlideRange(1).Shapes.AddPicture( ...
fullfile(matlabroot,'toolbox','images','imdemos','football.jpg'), ...
'msoFalse','msoTrue',200,220,500,500);
% 既に既存のプレゼンテーションを開いている場合、保存
%ppt.ActivePresentation.Save;
% 新規作成したプレゼンテーションを特定の場所に保存
ppt.ActivePresentation.SaveAs(fullfile(pwd,'test.ppt'));
% パワーポイントを閉じ、オブジェクトを削除
ppt.ActivePresentation.Close;
ppt.Quit;
ppt.delete;
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur ActiveX dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!