Merge multiple presentations into a single presentation

조회 수: 6 (최근 30일)
Ish
Ish 2017년 3월 29일
댓글: Ish 2017년 3월 30일
Hi,
I'd like to know the best syntax to follow for merging multiple presentations (without adding any new slides) into a new .pptx file . I'm not well versed with VBA and unable to find the right active x commands to do this.
I know that this question has been asked multiple times before but none of the suggested methods seem to be working well for me.
Any help is really appreciated!

채택된 답변

ES
ES 2017년 3월 29일
Did you try this?
https://in.mathworks.com/matlabcentral/fileexchange/340-saveppt

추가 답변 (1개)

Ish
Ish 2017년 3월 29일
편집: Ish 2017년 3월 29일
Thank you Smith. Was able to get it working with a combination of information from the above link shared by you and the following one: http://software-solutions-online.com/copy-slides-one-presentation-another-vba-powerpoint/
Posting a summary of the code snippet. Please suggest improvements if any:
filespec1 = 'D:\Copy_ppt.pptx';
filespec2 = 'D:\Paste_ppt.pptx';
ppt = actxserver('PowerPoint.Application');
op1 = invoke(ppt.Presentations,'Open',filespec1,[],[],0);
op2 = invoke(ppt.Presentations,'Open',filespec2,[],[],0);
slide_count1 = get(op1.Slides,'Count');
slide_count2 = get(op2.Slides,'Count');
k =slide_count2+1;
for i = 1 : slide_count1
invoke(op1.Slides.Item(i),'Copy')
invoke(op2.Slides,'Paste')
% invoke(op2.Item(k).Slides,'Paste)
k = k+1
end
invoke(op2,'Save');
% invoke(op2,'SaveAs',filespec2,1);
invoke(op1,'Close');
invoke(op2,'Close');
invoke(ppt,'Quit');
  댓글 수: 2
ES
ES 2017년 3월 30일
Very good piece of code. Only suggestion from my side is, can the for loop be eliminated? Is something like
invoke(op1.Slides.Item(1:slide_count1),'Copy')
invoke(op2.Slides,'Paste')
possible?
Ish
Ish 2017년 3월 30일
Tried eliminating the for loop. I see the following error :
"Error using Interface.91493469_5A91_11CF_8700_00AA0060263B/Item"
Error in ppt_01 (line 31)
invoke(op1.Slides.Item(1:slide_count1),'Copy')
I also see a similar error when I go back and try to run yesterday's piece of code:
"Error using Interface.9149349D_5A91_11CF_8700_00AA0060263B/Save"
Error in ppt_01 (line 36)
invoke(op2,'Save');
Undefined function 'Item' for input arguments of type
'Interface.9149349D_5A91_11CF_8700_00AA0060263B'.
Error in ppt_01 (line 27)
invoke(op2.Item(k).Slides,'Paste')
I am not sure of how to resolve this.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 ActiveX에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by