How to add image in existing ppt with matlab code

조회 수: 36 (최근 30일)
Ashwini  More
Ashwini More 2020년 1월 27일
편집: Ashwini More 2020년 1월 28일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Update PowerPoint Presentation Content에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by