Merge multiple presentations into a single presentation

8 vues (au cours des 30 derniers jours)
Ish
Ish le 29 Mar 2017
Commenté : Ish le 30 Mar 2017
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!

Réponse acceptée

ES
ES le 29 Mar 2017
Did you try this?
https://in.mathworks.com/matlabcentral/fileexchange/340-saveppt

Plus de réponses (1)

Ish
Ish le 29 Mar 2017
Modifié(e) : Ish le 29 Mar 2017
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 commentaires
ES
ES le 30 Mar 2017
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 le 30 Mar 2017
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.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by