When you want to make and write data in PPT file (without API),
You can use this.
This example loads a pre-writed PPT template file and connects data to item ID values. (using VBA)
#PPT Template
# Code
DesktopPath = winqueryreg('HKEY_CURRENT_USER', 'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'Desktop');
PPTFile = 'PPT_Template.pptx';
%// Open PPT
p = actxserver('PowerPoint.Application');
ppt = p.Presentations.Open(strcat(DesktopPath, PPTFile));
%// Set Text
ppt.slides.Item(1).Shapes.Item(1).TextFrame.TextRange.Text = "New Title";
ppt.slides.Item(1).Shapes.Item(2).TextFrame.TextRange.Text = "New Sub_Title";
%// Delete Item
ppt.slides.Item(1).Shapes.Item(3).Delete;
ppt.slides.Item(1).Shapes.Item(4).Delete;
ppt.slides.Item(1).Shapes.Item(5).Delete;
%// Slide Duplicate
CopySlide1 = ppt.slides.Item(1).Duplicate;
CopySlide2 = ppt.slides.Item(1).Duplicate;
%// Another way to set text
set(CopySlide1.Shapes.Item(1).TextFrame.TextRange, 'Text', "New Title (in a New Slide)");
%// Slides Count
SlidesCount = ppt.slies.count;
%// Slides Move
CopySlide1.MoveTo(SlidesCount);
%// Add Picture. [Position 100 x 100, Size 200 x 200 (point)]
img = strcat(DesktopPath, '\Img.png');
CopySlide1.Shapes.AddPicture(img, 'msoFalse', 'msoTrue', 100, 100, 200, 200);
%// Save ppt
NewPPTName = fullfile(DesktopPath, 'NewPPT.pptx');
ppt.SaveAs(NewPPTName);
You can refer other VBA methods here
https://docs.microsoft.com/en-us/office/vba/api/powerpoint.shapes.addpicture
'Memo > Matlab' 카테고리의 다른 글
Matlab : Prepare the Machine Learning Param Table (0) | 2022.11.12 |
---|---|
Matlab function : Change the Enable of several UIs (0) | 2022.08.09 |
Matlab function : Save and load UI values in text (0) | 2022.08.08 |
Matlab function : Update the Text Area with part of a text file (0) | 2022.08.02 |
Matlab : UI drop-down (0) | 2022.08.01 |