批量设置PowerPoint字体及行间距——VBA宏
时间: 2023-07-31 16:08:08 浏览: 229
好的,以下是一个示例代码,可以批量设置PowerPoint幻灯片中所有的文本框的字体和行间距:
```
Sub SetTextFontAndLineSpacing()
Dim oSlide As Slide
Dim oShape As Shape
Dim oTextFrame As TextFrame
Dim oParagraph As Paragraph
Dim oFont As Font
For Each oSlide In ActivePresentation.Slides
For Each oShape In oSlide.Shapes
If oShape.HasTextFrame Then
Set oTextFrame = oShape.TextFrame
For Each oParagraph In oTextFrame.TextRange.Paragraphs
Set oFont = oParagraph.Font
oFont.Name = "微软雅黑" '更改字体名称
oParagraph.LineSpacing = 1.5 '更改行间距
Next oParagraph
End If
Next oShape
Next oSlide
End Sub
```
这个代码将遍历幻灯片中所有的形状,如果形状包含文本框,则设置文本框中每个段落的字体为微软雅黑,行间距为1.5倍行距。您可以根据自己的需要更改字体名称和行间距。希望对您有帮助!