How to add image in existing ppt with matlab code

26 次查看(过去 30 天)
I have standard powerpoint format in which I want to add graphs of different applications. and this procedure is repetative. so can someone tell me how can I do this with matlab code?
  1 个评论
Ashwini  More
Ashwini More 2020-1-28
here is the code for open existing ppt and get the no of slides.
Now next task is that how can I replace figures by new figures from existing slides
Thank you in advance!!
clear all; clc;
project_dir = pwd(); %new
% List all current folder contents ending with .png. Resulting names will
% appear in the order returned by the operating system.
files = dir( fullfile(project_dir, '*.png')); %changed
% Create Common Object Model (COM) server so MATLAB can export data to
% PowerPoint
g = actxserver('powerpoint.application');
% Open PowerPoint and make it visible
g.Visible = 1;
Presentation = g.Presentation;
% Prompt the user for the PowerPoint file to amend
[fn, pn] = uigetfile('*.pptx', 'Select PowerPoint File To Amend');
filename = fullfile(pn, fn); %changed
Presentation = invoke(Presentation, 'open', filename);
% Get current number of slides
slide_count = get(Presentation.Slides, 'Count');

请先登录,再进行评论。

回答(1 个)

Selva Karna
Selva Karna 2020-1-28
clc
clear all;
close all;
import mlreportgen.ppt.*
slidesFile = 'myPicturePresentation.pptx';
slides = Presentation(slidesFile);
add(slides,'Title Slide');
add(slides,'Title and Content');
plane = Picture(which('b747.jpg'));
plane.Width = '5in';
plane.Height = '2in';
replace(slides,'Content',plane);
close(slides);
  2 个评论
Walter Roberson
Walter Roberson 2020-1-28
This requires the MATLAB Report Generator, I believe.
It would help if the code could show selecting a particular slide given the index.
Ashwini  More
Ashwini More 2020-1-28
编辑:Ashwini More 2020-1-28
I have tried this earlier but it does not completely apply to my application.
earlier code adds image in new slide but I want to add in only in existing slide
Is there any way by which I can add image to specific existing slide in specified location?
actually my task is to only update .png file into std format of ppt which is repetative work
my ppt format is of following type:
matlab.PNG

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by