Error using AddPicture method on Slide obj opened with PowerPoint Application (No method 'AddPicture' with matching signature found for class 'Interface.91493475_5A91... )
22 views (last 30 days)
Show older comments
Hi everyone,
I am facing an issue trying to add some pictures on pptx presentation using actxserver, please find attached below my code. I added some inline comments trying to explain what I would like to do. I did some researches but I couldn't solve this issue. (I have matlab 2018)
Basically I have a pptx template stored in a folder and some pitcures. Picture are stored in a folder ad .png extension. I checked them and matlab can open them with imshow, so shouldn't be any issue there.
% I get the files path
files = dir('C:\Users\myUser\Desktop\_cache')
h = actxserver('PowerPoint.Application');
try
% the path is a folder on the desktop, I dont know if this might be an issue
% I checked the file and is not read only
path = 'C:\Users\myUser\Desktop\_templates'
PresentationObj = h.Presentation.Open([path '_templates\Report_Template.pptx']);
end
% The third slide of my report is empty. I would like to duplicate it and than add the picture inside
% each new slide
for i = 3 : length(files)
PresentationObj.Slides.Item(3).Duplicate;
end
for i = 3 : length(files)
picturePath = [files(i).folder '\' files(i).name]
NewSlide = PresentationObj.Slides.Item(i);
try
%%%%%% Here is where i get the error!
NewSlide.Shapes.AddPicture(picturePath,'msoFalse','msoTrue',[100 100 1000 1000])
end
end
%save and close
PresentationObj.SaveAs([savingPath strrep(strrep(datestr(datetime('today')), '-', '_'), ':', '_') '_Report.pptx'])
h.Quit;
h.delete;
The error is this one:
No method 'AddPicture' with matching signature found for class 'Interface.91493475_5A91_11CF_8700_00AA0060263B'
Now, It is pretty weird to me, because I did something similar in the past and worked well. Nevertheless I am not able to do it with this piece of code. The only thing It comes into my mind is some issues with where pictures and template have been stored. I did some test moving the files elsewhere but the situation didn't improve.
Thanks in advance for your help and hope everything is clear.
Cheers
MT
0 Comments
Answers (1)
Piyush Dubey
on 7 Sep 2023
In my understanding you are trying to add some pictures to your slide object created for a power point application which are in ‘.png’ extension. While performing this operation you are facing an error stating that the function signature does not match the inputs entered by you.
Please know that “AddPicture” method is used to insert figures in a document (Word, Presentation, Sheet, etc.). The syntax for “AddPicture” is:
expression.AddPicture(Filename, LinkToFile, SaveWithDocument, Left, Top, Width, Height);
where expression is a variable that represents a shapes object. The code snippet attached seems to indicate a list data type used for coordinates instead of individually entering coordinate values for ‘Left’, ‘Top’, ‘Width’ and ‘Height’ respectively.
Please refer to the following MATLAB Answers thread which addresses a similar issue:
Hope this helps.
0 Comments
See Also
Categories
Find more on MATLAB Report Generator in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!