Hi Sarah,
You can automate PowerPoint using MATLAB's ActiveX interface to replace both images and text across multiple slides. Before implementing the solution, it's important to note that you need to know the shape indices of the text boxes and images in your presentation - in this solution, I'm assuming the first three shapes are text boxes and the fourth shape is an image.
Here's the simple MATLAB code replacing images and texts in the slides:
pptApp = actxserver('PowerPoint.Application');
pptFileName = fullfile(pwd, 'try.pptx');
ppt = pptApp.Presentations.Open(pptFileName);
slide = ppt.Slides.Item(slideNum);
newText1 = sprintf('This is new text for box 1 on slide %d', slideNum);
newText2 = sprintf('This is new text for box 2 on slide %d', slideNum);
newText3 = sprintf('This is new text for box 3 on slide %d', slideNum);
newImagePath = fullfile('images/', sprintf('%d.jpg', slideNum));
for i = 1:slide.Shapes.Count
shape = slide.Shapes.Item(i);
shapeType = char(shape.Type);
if strcmp(shapeType, 'msoTextBox')
textFrame = shape.TextFrame;
textFrame.TextRange.Text = newText1;
textFrame.TextRange.Text = newText2;
textFrame.TextRange.Text = newText3;
elseif strcmp(shapeType, 'msoPicture')
slide.Shapes.AddPicture(...
The code iterates through each slide and automatically identifies text boxes and pictures based on their shape type, then replaces them with new content while preserving their original positions.
Hope this helps!