Create a fraction

Home Up Search This Site What's New? Audio On CDR Favourites Downloadable files Photo Gallery 2002 Photo Gallery 2003 Photo Gallery 2004/5 Photo Gallery 2006/7 Photo Gallery 2008 Photo Gallery 2009/10 Photo Gallery 2011 Photo Gallery 2012 UK Photo Gallery Ireland Photo Gallery Cats Photo Gallery 

horizontal rule

 

 

Google
 

 

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, however small, 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 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


 

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