Graham Mayor

... helping to ease the lives of Microsoft Word users.

Many people access the material from this web site daily. Most just take what they want and run. That's OK, provided they are not selling on the material as their own; however if your productivity gains from the material you have used, a donation from the money you have saved would help to ensure the continued availability of this resource. Click the appropriate button above to access PayPal.

Create a fraction

Using Word's autocorrect function, certain fonts allow fractions entered in text in the format 1/2 to be corrected to use the matching font character ½. This is all very well if the font has the required characters, but you will be struggling when you get around to 35/278 for example.

The Word MVP web site offers a useful approach to creating formatted fractions involving Word's EQ field, but here I suggest an alternative approach using a macro to format any selected fraction in the format number/number. Thus the suggested 35/278 becomes 35278.

This actually looks better when used in Word than it does in the browser e.g.

The Macro Code

Sub FmtFraction()
Dim sFraction() As String
Dim sChar As String
'Check if a fraction is selected
'and if not show a warning and exit
If InStr(Selection, "/") = False Then
 MsgBox "No fraction selected!", vbCritical, "Format Fraction"
 Exit Sub
End If
'Define a new slash character
sChar = ChrW(&H2044)
'Split the original fraction at the slash character
sFraction = Split(Selection, "/")
'Reformat the fraction using super and subscript
With Selection
 .Font.Superscript = True
 .TypeText Text:=sFraction(0)
 .Font.Superscript = False
 .TypeText Text:=sChar
 .Font.Subscript = True
  TypeText Text:=sFraction(1)
 .Font.Subscript = False
End With
End Sub

 

If you do not know how to employ this code, see the tutorial elsewhere on this site.

 

 

Fractions

Using Word's autocorrect function, certain fonts allow fractions entered in text in the format 1/2 to be corrected to use the matching font character ½.

This is all very well if the font has the required characters, but you will be struggling when you get around to 35/278 for example.