Skip to content

Commit

Permalink
INIT commit
Browse files Browse the repository at this point in the history
  • Loading branch information
eeshaansawant committed Dec 14, 2024
1 parent 020da8d commit 2efd95a
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- 404 page
- legacy version link
- macros: added add comments and change cell colors in spreadsheet macro sample
- macros: added change font family and size in presentations macro sample

## 6.1.0
- docspace js sdk: react component
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
order:
---

## Description

Change font family and size on all slides in your presentation.

<!-- This code snippet is shown in the screenshot. -->

<!-- eslint-skip -->

```ts
(function () {
var oPresentation = Api.GetPresentation();
for (
var slideIndex = 0;
slideIndex < oPresentation.GetSlidesCount();
slideIndex++
) {
var oSlide = oPresentation.GetSlideByIndex(slideIndex);
var aShape = oSlide.GetAllShapes();

for (var shapeIndex = 0; shapeIndex < aShape.length; shapeIndex++) {
var content = aShape[shapeIndex].GetDocContent();
// Check if content is valid before proceeding
if (content) {
var count = content.GetElementsCount();
for (var elementIndex = 0; elementIndex < count; elementIndex++) {
var 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

<!-- code generated with AI -->

```vb
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
```

## Result

<!-- imgpath -->

![Change font family and size](/assets/images/plugins/change-font-family-size.png)
4 changes: 4 additions & 0 deletions site/pages/Docs/Plugin and Macros/Macros/Samples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ In this example we are adding comments and changing the background colors of sel

[More](Add%20comments%20and%20change%20cell%20colors%20in%20spreadsheet/index.md)

## Change font family and size

In this example we are changing font family and/or size in the presentation.

## Support

If you want to request a feature or report a bug regarding macros, use the issues section [on GitHub.](https://github.com/ONLYOFFICE/plugin-macros/issues)
Expand Down

0 comments on commit 2efd95a

Please sign in to comment.