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 UK Photo Gallery Ireland Photo Gallery Cats Photo Gallery 

 

 

Google
 

 

 

There is no charge for using any of the material (for personal use) on this web site, but if you wish to make a contribution to the ever growing running costs, any donation would be much appreciated. Click the adjacent button 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 OrigFrac As String
Dim
Numerator As String

Dim Denominator As String
Dim
NewSlashChar As String
Dim
SlashPos As Integer
NewSlashChar = ChrW(&H2044)
OrigFrac = Selection
SlashPos = InStr(OrigFrac, "/")
Numerator = Left(OrigFrac, SlashPos - 1)
Denominator = Right(OrigFrac, Len(OrigFrac) - SlashPos)
With Selection
  .Font.Superscript = True
  .TypeText Text:=Numerator
  .Font.Superscript = False
  .TypeText Text:=NewSlashChar
  .Font.Subscript = True
  .TypeText Text:=Denominator
  .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.