Joe*_*Net 7 excel vba font-size excel-vba word-vba
有一种简单的方法可以在VBA中通过1步减少Word/Excel中的字体大小吗?
因此,如果我的字体大小是48,我可以轻松地将其减少到36,根据标准Word 2007字体组中的字体下拉菜单,而不是将字体大小减小12 - 我不知道下一个字体大小是什么下来是......
因此,不要通过float显式设置字体大小:
MyText.Font.Size = 36;
Run Code Online (Sandbox Code Playgroud)
我可以这样做:
MyText.Font.Size -= Reduce by 1 step;.... forgive the pseudo code!
Run Code Online (Sandbox Code Playgroud)
对于Excel,您可以在"格式"工具栏上检查"字体大小"组合框.这是2003年的东西,我认为它仍然可以在2007年及以后工作,但我没有它可用于测试.
Sub FontShrink(rng As Range)
Dim i As Long
Dim ctl As CommandBarComboBox
Set ctl = Application.CommandBars("Formatting").Controls("Font Size:")
If rng.Font.Size > CDbl(ctl.List(ctl.ListCount)) Then
'if it's bigger than the biggest, make it the biggest
rng.Font.Size = ctl.List(ctl.ListCount)
Else
For i = ctl.ListCount To 2 Step -1
If rng.Font.Size > CDbl(ctl.List(i)) Then
rng.Font.Size = CDbl(ctl.List(i))
Exit For
ElseIf rng.Font.Size = CDbl(ctl.List(i)) Then
rng.Font.Size = CDbl(ctl.List(i - 1))
Exit For
End If
Next i
End If
End Sub
Run Code Online (Sandbox Code Playgroud)