add new slides to an exisiting powerpoint within a while loop in matlab

To add new slides to an existing PowerPoint presentation within a while loop in MATLAB, you can use the following code:

main.m
% Connect to an already opened PowerPoint Application
ppt = actxserver('Powerpoint.Application');
% Get the current active presentation
curr_presentation = ppt.ActivePresentation;
% Start the while loop
while (condition)
    % Add a new slide to the current PowerPoint presentation
    new_slide = curr_presentation.Slides.Add(curr_presentation.Slides.Count+1, 11);
    % Do your desired operations with the new slide
    % ...
    % Change the condition in order to end the loop
end
% Close PowerPoint Application
ppt.Quit;
525 chars
15 lines

In the above code, we first connect to an already opened PowerPoint application using the actxserver function. Then, we get the active presentation using the ActivePresentation property. After that, we start a while loop with the desired condition, inside the loop we add new slides to the current presentation using the Slides.Add method. The first argument of this method is the index of the slide to insert, and the second argument is the type of the slide (11 for a Blank slide in this example). Lastly, after finishing the loop, we close the PowerPoint application using the Quit method.

related categories

gistlibby LogSnag