fractions - entering your own numbers in Word?

J

John

Hello.

When I used to own Ami Pro decades ago, I used to be able to enter a
fraction but to enter my own numbers into it. Is there a way I can do
this in Word.

For example I might want to enter a fraction that has a strange number
eg 113/147 or I might even want to use letters.

Thanks very much for any help

John
 
J

Jezebel

The 'built-in' fractions are a dependent on the font -- some fonts have 1/2,
1/4 etc as actual characters. Any other fraction has to be constructed. You
can use the equation editor, or a miniature table (one column, two rows), or
two tiny text boxes and a line. Amongst other methods.
 
G

Greg Maxey

John,

A friend just posted a new web-page article on this topic. See:

http://www.gmayor.com/createfraction.htm

I have been monkeying around with his code and offer the following as an
alternative for inserting fractions:

Sub InsertFraction()
Dim DenMsgBox As VbMsgBoxResult
Dim Expr As String
Dim Numerator As String, Denominator As String
Dim NewSlashChar As String
Dim SlashPos As Integer
NewSlashChar = ChrW(&H2044)
Retry:
Expr = InputBox("Enter the fraction as numerator/denominator (e.g., 3/4,
a/b, etc.):", "Enter Fraction")
If Expr = "" Then GoTo Cancel
SlashPos = InStr(Expr, "/")
If SlashPos = 0 Or SlashPos = 1 Then
MsgBox "Format must be numerator/denominator (e.g., 3/4, a/b, etc.). Please
try again.", , "Format Error"
GoTo Retry
Else
Numerator = Left(Expr, SlashPos - 1)
Denominator = Right(Expr, Len(Expr) - SlashPos)
If Denominator = "0" Then
DenMsgBox = MsgBox("The denominator is a null value. Do you want to
override?", vbYesNo, "Illogical Expression")
Else: GoTo Convert
End If
If DenMsgBox = vbNo Then
GoTo Retry
Else
Convert:
Selection.Font.Superscript = True
Selection.TypeText Text:=Numerator
Selection.Font.Superscript = False
Selection.TypeText Text:=NewSlashChar
Selection.Font.Subscript = True
Selection.TypeText Text:=Denominator
Selection.Font.Subscript = False
End If
End If
Cancel:
End Sub
 
Top