forked from rozenasf/Matlab2Powerpoint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Untitled4.m
91 lines (72 loc) · 2.35 KB
/
Untitled4.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
fullpath = mfilename('fullpath');
[pathstr1,~,~] = fileparts(fullpath);
addpath(genpath(pathstr1));
% Drive into toPPT folder.
cd(pathstr1);
clear pathstr1 fullpath;
%%
toPPT('setPageFormat','16:9');
%%
% figure(1);pcolor(rand(10,10));
% toPPT(figure1,'pos%',[posPercentageX,posPercentageY],'Height%',30,'posAnker','NW');
toPPT(gcf,'pos%',[25,25],'Height%',30,'posAnker','NW');
%%
saveFilename = 'test';
toPPT('saveFilename',saveFilename);
%%
ppt = actxserver('PowerPoint.Application');
ppt.Visible = 1;
% pres = ppt.Presentations.Add;
pres = get(ppt,'ActivePresentation');
slide3=pres.Slides.Item(3);
myFIg=figure(); %create the figure to test
plot([0 1],[1 1],'m');
print('-dmeta',myFIg) % copy to clipboard
pic = slide3.Shapes.PasteSpecial().Item(1);
%% Analyze Powerpoint
tic
ppt = actxserver('PowerPoint.Application');
ppt.Visible = 1;
pres = get(ppt,'ActivePresentation');
Number_Of_Slides = pres.Slides.Count;
Slide = {};
Properties = {'name','top','left','width','height'};
for i=1:Number_Of_Slides
Slide{i}=[];
Slide{i}.obj=pres.Slides.Item(i);
for j=1:Slide{i}.obj.Shapes.Count
Slide{i}.Item{j}=[];
Slide{i}.Item{j}.obj = Slide{i}.obj.Shapes.Item(j);
end
end
toc
%%
title_slide = invoke( pres.Slides,'Add',1,1 ); % Add Title Slide
title = get( title_slide.Shapes.Item(1) ); % Get Handle to title shape
subtitle = get( title_slide.Shapes.Item(2) ); % Get Handle to subtitle shape
set(title.TextFrame.TextRange ,'Text','Title' ); % Set Title Text to 'Title'
set(subtitle.TextFrame.TextRange,'Text','Subtitle'); % Set Subtitle Text to 'Subitle'
%%
%%
ToReplace = 'HIHI';
myFIg=figure(1); %create the figure to test
plot(rand(10,2));
print('-dmeta',myFIg) % copy to clipboard
%%
tic
FigureNumber=34;
resolution='300';
Path = 'C:\Users\asafr\Desktop\jrichter24-toPPT-ce09cf0\jrichter24-toPPT-ce09cf0\';
handles=findall(0,'type','figure');
ind = find([handles.Number] == FigureNumber);
if(isempty(ind)); return ;end
figure_handle = handles(ind);
% figure_handle.Position
[MatlabPPT, Change] = RefreshPPT();
Obj = Obj_From_Placeholder(['figure',num2str(FigureNumber)],MatlabPPT);
figure_handle.Position(4) = Obj.Height./Obj.Width * figure_handle.Position(3);
print(figure_handle,[Path,'temp.jpg'],'-dpng',['-r',resolution]);
ReplaceImage(Obj,[Path,'temp.jpg']);
toc
%%
Connect_Figure_To_Powerpoint()