Change font family and size
Changes the font family and/or size on all the slides in your presentation.
(function () {
let presentation = Api.GetPresentation();
for (
let slideIndex = 0;
slideIndex < presentation.GetSlidesCount();
slideIndex++
) {
let slide = presentation.GetSlideByIndex(slideIndex);
let shapes = slide.GetAllShapes();
for (let shapeIndex = 0; shapeIndex < shapes.length; shapeIndex++) {
let content = shapes[shapeIndex].GetDocContent();
// Check if content is valid before proceeding
if (content) {
let count = content.GetElementsCount();
for (let elementIndex = 0; elementIndex < count; elementIndex++) {
let element = content.GetElement(elementIndex);
// Check if element is valid before using it
if (element) {
element.SetFontSize(10);
element.SetFontFamily("Comic Sans");
}
}
}
}
}
})();
Methods used: GetPresentation, GetSlidesCount, GetSlideByIndex, GetAllShapes, GetDocContent, GetElementsCount, GetElement, SetFontSize, SetFontFamily
Reference Microsoft VBA macro code
Sub ChangeFontOnAllSlides()
Dim slide As slide
Dim shape As shape
' Loop through each slide in the presentation
For Each slide In ActivePresentation.Slides
' Loop through each shape on the slide
For Each shape In slide.Shapes
' Check if the shape has text
If shape.HasTextFrame Then
If shape.TextFrame.HasText Then
With shape.TextFrame.TextRange
.Font.Name = "Arial"
.Font.Size = 20
End With
End If
End If
Next shape
Next slide
MsgBox "Font updated on all slides!", vbInformation
End Sub