Thanks Greg
Greg,
Nothing covers the latter in the sense the special
characters 1/4, 1/2, etc. you mention are part of the font
set while 1/8 is not. For detailed explanation and for
formatting fraction existing in your document, see:
http://www.gmayor.com/createfraction.htm
To insert formatted fraction:
Sub InsertFraction()
Dim DenMsgBox As VbMsgBoxResult
Dim Expr, Numerator, Denominator, 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 Exit Sub
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
End Sub