Decrease font size by 1 step in VBA

Is there an easy way to reduce the font size in Word / Excel, etc. 1 step in VBA?

So, let's say if my font size was 48, I could reduce it to 36, easily, since the font fell out in the standard Word 2007 font group, instead of decreasing the font size by 12 - I won’t know that the next font size is down ...

Therefore, instead of explicitly setting the font size using float:

MyText.Font.Size = 36; 

could i do something like:

 MyText.Font.Size -= Reduce by 1 step;.... forgive the pseudo code! 
+6
source share
3 answers

In Excel, you can view the font list box on the formatting toolbar. This material is 2003, and I think that it will still work in 2007 and beyond, but I do not have it for testing.

 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 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 
+5
source

Use the Font Object Shrink Method:

 MyText.Font.Shrink 

The opposite of MyText.Font.Grow .

+3
source

You can grow and shrink fonts.

+3
source

Source: https://habr.com/ru/post/889941/


All Articles