在 PowerPoint 中使用 VBA 更改字体 [英] Using VBA in PowerPoint to change font
本文介绍了在 PowerPoint 中使用 VBA 更改字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用 VBA 使整个 PowerPoint 演示文稿的字体保持一致?
How do I use VBA to make the font consistent throughout a PowerPoint presentation?
我是 VBA 新手,所以我使用的代码可能完全错误,但这里是:
I'm new to VBA, so the code I used could be completely wrong but here it is:
Sub FontChange()
Dim sld As Slide
Dim shp As Shape
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
shp.TextFrame.TextRange.Font
.Size = 12
.Name = "Bauhaus 93"
.Bold = False
.Color.RGB = RGB(255, 127, 255)
Next shp
Next sld
End Sub
预先感谢您的帮助.
推荐答案
如果您想要更改不在占位符中的文本,可以对 Wayne 的版本进行一些修改.并进行一些测试以确保有问题的形状 a) 可以包含文本(线条等形状不能),如果是,则 b) 它有一些文本需要修改.
A few mods to Wayne's version in the event that you want to change text that's not in placeholders. And a few tests to make sure that the shape in question a) CAN contain text (shapes like lines cannot) and if so b) that it HAS some text to modify.
Option Explicit
Sub FontChange()
Dim sld As Slide
Dim shp As Shape
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.HasTextFrame Then ' Not all shapes do
If shp.TextFrame.HasText Then ' the shape may contain no text
With shp.TextFrame.TextRange.Font
.Size = 12
.Name = "Bauhaus 93"
.Bold = False
.Color.RGB = RGB(255, 127, 255)
End With
End If
End If
Next shp
Next sld
End Sub
这篇关于在 PowerPoint 中使用 VBA 更改字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文