App designer, export an image to word
7 次查看(过去 30 天)
显示 更早的评论
Hi all,
I am writing a small program in App designer that calculates a few things and then it inserts the results in a Word document.
Moreover in should also insert an a corresponding image for the calculation - say a free body diragram.
The first part of wirting the results to word is not a problem, but i am struggling with the last part of inserting an image.
The images is small drawings in PNG formate i made myself.
Heres is a small section from what i got so fare:
%Opning a wordfile, called Solutions
fid = fopen('Solutions.doc','w');
% æ ø å char(230),char(248),char(229)
%the first line in the word doc, writes "bulding height"
fprintf(fid,'building height');
%Adds line space
fprintf(fid,'\n');
%Writes h =, which is a abbreviation for height
fprintf(fid,'h = ');
%Inserts the user specified height of the buliding
fprintf(fid,'%d', h);
%Writes the unit of the userinput (height = meters)
fprintf(fid,' [m]\n');
%Adds a new linespacing
fprintf(fid,'\n');
%%%%%Insert the image building_height.PNG%%%%% here an image of my choosing of a building should be displayed in the word document.
I have looked through a lot of exsampels in here, also the Save2Word function. Non of it seems to work for me.
I hope my question makses sense, and thanks in advance
Regards Steffen
0 个评论
采纳的回答
Nicolas B.
2019-12-4
编辑:Nicolas B.
2019-12-4
Otherwise, you should use the COM server to interact with word.
2 个评论
Nicolas B.
2019-12-4
May I ask you to edit your post to put your code in code mode? It will be easier for everybody to read and follow your message.
Than, I tried your code with this configuration:
- MATLAB R2019b
- Office 365
What configuration do you have on your computer?
I haven't got problems with ActiveX or the COM-Server. However, I would recommand you to use fullfile to reconstruct path safely:
img = fullfile(pwd, 'picture.png');
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!