【发布时间】:2020-02-26 19:58:19
【问题描述】:
我正在尝试根据用户输入的字体更改 PowerPoint 演示文稿中所有文本的字体,但是当我尝试时它不会改变任何内容。我哪里错了?有没有更好的方法来实现这个……比如用字体下拉框或其他东西?因为我也想实现字体大小/粗体/斜体等。谢谢!
Sub ChangeFont()
Dim bpFontName As String
bpFontName = InputBox("What font would you like to change EVERYTHING to?")
With ActivePresentation
For Each Slide In .Slides
For Each Shape In Slide.Shapes
With Shape
If .HasTextFrame Then
If .TextFrame.HasText Then
.TextFrame.TextRange.Font.Name = bpFontName
'Set font size below
.TextFrame.TextRange.Font.Size = 30
'Set if you want the font bold below - msoFalse = no
.TextFrame.TextRange.Font.Bold = msoTrue
'Set if you want the font bold below - msoFalse = no
.TextFrame.TextRange.Font.Italic = msoTrue
End If
End If
End With
Next
Next
End With
End Sub
【问题讨论】:
-
如果在
bpFintName = ...处设置断点并按F8 单步执行代码会怎样?
标签: vba powerpoint