Clear Filters
Clear Filters

Merge powerpoint presentations on Apple Silicon

1 view (last 30 days)
oran
oran on 3 Jan 2024
Edited: Divyanshu on 31 Jan 2024
Is there a way to merge multiple powerpoint (pptx) files into a single .pptx from within the matlab report generator or any other know submission on Apple Silicon? IE - without com objects or activeX? Bonus points if I can then export as a PDF, but this seems like a long shot.
exportToPPTX seems promising, but as of yet I cannot get it to work.
  2 Comments
Divyanshu
Divyanshu on 30 Jan 2024
Edited: Divyanshu on 30 Jan 2024
Hi Oran,
Any specific use-case why you want to merge the presentations without using activeX or actxserver or COM objects? I am asking this because it would be relatively easier to merge the presentations using actxserver and similar COM objects.
oran
oran on 30 Jan 2024
@Divyanshu - my understanding is that com objects / activex are available on windows machines only. I've got this pretty sorted in the windows environment, but my clients are using both windows and mac computers.

Sign in to comment.

Answers (1)

Divyanshu
Divyanshu on 31 Jan 2024
Edited: Divyanshu on 31 Jan 2024
Hi Oran,
Without using actxserver a lot of manual-coding is required to merge the presentations specifically using 'mlreportgen'. You can refer the following sample code which can be a possible workaround:
Please refer the following pointers to understand the code:
  • This piece of code initially creates two presentations 'file1.pptx' & 'file2.pptx'.
  • After that a new slide is added to 'file1' and then we are going to replace the title and contents of this new slide.
  • The slide contents are replaced with the current slide of 'file2.pptx'
import mlreportgen.ppt.*
ppt = Presentation('file1.pptx');
open(ppt);
titleSlide = add(ppt,'Title Slide');
replace(titleSlide,'Title','Presentation Title 1');
contentSlide1 = add(ppt,'Title and Content');
replace(contentSlide1,'Title','This is the Title of the Content Slide for Presentation 1');
blankSlide = add(ppt,'Blank');
ppt2 = Presentation('file2.pptx');
open(ppt2);
titleSlide = add(ppt2,'Title Slide');
replace(titleSlide,'Title','Presentation Title 2');
contentSlide2 = add(ppt2,'Title and Content');
replace(contentSlide2,'Title','This is the Title of the Content Slide for Presentation 2');
replace(contentSlide2,'Content','A dummy content for presentation 2');
close(ppt2);
open(ppt);
contentSlide = add(ppt,'Title and Content');
newTitle = contentSlide2.Children(1).Children(1).Children(1).Content; %reading the title from slide of presentation2
newContent = contentSlide2.Children(2).Children(1).Children(1).Content; %reading the content from slide of presentation2
replace(contentSlide,'Title',newTitle);
replace(contentSlide,'Content',newContent);
close(ppt);
rptview(ppt);
Note: I have created only two slides for input presenations and the object which refers the slide of ppt2 is static here and may be required to make it dynamic by attaching to some loop based on use-case.
Hope it helps!

Categories

Find more on MATLAB Report Generator in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!