Caught "std::exception" Exception message is: createInputStream failed:

Hi all,
I'm working on a program in MATLAB 2019b to analyze test data and automatically generate a PowerPoint report of the results using mlreportgen.ppt. The code is set up to use a template to create the presentation and replace various uniquely named picture placeholders with the figures it generates. I unfortunately can't post my exact code, but here is a recreation of the relevant portions:
import mlreportgen.ppt.*
template = 'myTemplate.pptx';
newSlides = 'finalReport.pptx';
slides = Presentation(newSlides,template);
%code to generate plot
saveas(gcf, 'Fig1.png');
replace(slides,'Picture Placeholder Name', Picture('Fig1.png'));
close(slides);
The error is occurring at close(slides), and gives the following error message:
Caught "std::exception" Exception message is:
createInputStream failed:
In addition to replacing figures, the code is also set up to replace to replace titles and various textboxes in the PowerPoint. When you run the code without the commands to replace the pictures (leaving commands to replace text), it works fine, and when I give the close(slides) command, it generates a PowerPoint with the replaced text and all of the slides from the template. The error only occurs when I try to replace the picture placeholders with figures. When I inlude those commands, the resulting PowerPoint still has the replaced text, but all of the slides after the first slide I attempt to replace a picture on are deleted. I wasn't able to find any info on the exact error, but a similar error recommended using fclose('all') to solve it. I've tried including that command before close(slides), and it didn't help.
Have any of you encountered this error before? Thank you in advance for your help!

3 commentaires

I would check to be sure that finalReport.pptx and Fig1.png in the current directory were both writable (that is, that the current directory is one you can write to, and those two files do not already exist in locked form.)
Thank you for your response! Both files are writeable, but double checking that info did end up leading me to the issue. I was saving the plots to a subfolder of the directory, and I didn't specify the subfolder in the replace function. Adding the full file path fixed the issue.
Hello Stephanie Farney, could you please elaborate with an example. I am running into almost the exact issue you have and need some further insight.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur MATLAB Report Generator dans Centre d'aide et File Exchange

Commenté :

le 10 Fév 2023

Community Treasure Hunt

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

Start Hunting!

Translated by