Last Saved .PNG uploaded on all PPT slides
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
For some reason my code would only upload my last saved .png file on all my PPT generated slides. I don't have this issue if i make a for loop for each image but that'd be too tedious. My code is supposed to upload each saved plot onto separate PPT slides.
Does the issue lie in the replace() function or the for loop statement? I labeled below
The code:
a = fileLength; % fileLength = 6 in this example
for j = 3:length(a) %The issue may lie here
imgFIG = openfig(strcat(fileList(j).folder,'\',fileList(j).name));
saveas(imgFIG,'plot6.png');
imgPNG = imread('plot6.png');
imgPNG2 = imresize(imgPNG, 1.5);
imwrite(imgPNG2,'plot7.png')
imgPNG3 = Picture('plot7.png');
fName = fileList(j).name;
z = fName(27:28);
dataSlides = add(ppt,'Title and Content');
newTitle = strcat('Step', {' '}, z,' Simulations');
replace(dataSlides,'Title', newTitle);
replace(dataSlides,'Content', imgPNG3); %The issue may lie here
clearvars -except j pL ppt directory fileList dirSize a
end
0 Kommentare
Antworten (1)
Image Analyst
am 4 Dez. 2023
What does this line do:
dataSlides = add(ppt,'Title and Content');
What is ppt? I'd use ActiveX if you're using Windows.
Why are you calling clearvars? I'd get rid of that. It's not necessary.
And if
a = fileLength; % fileLength = 6 in this example
then
1:length(a)
so the loop only happens once because length(6) = 1. The length of a scalar is just one value. Try
for j = 3: a % For j = 3, 4, 5, and 6
5 Kommentare
Image Analyst
am 5 Dez. 2023
I don't think I can help more unless I have the full code, like where you instantiate ppt.
Can you use ActiveX (i.e. are you on Windows and willing to use it)?
Siehe auch
Kategorien
Mehr zu Update PowerPoint Presentation Content finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!