
Signature
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
Yes I have some fraction macros and some of the images. I just don't
remember how I had it put together. Here is a couple of macros. The first
inserts a fraction with a EQ field construction, the second directly formats
a fraction:
Public Sub Fraction()
Dim oNum As String
Dim oDen As String
Do
oNum = InputBox("Enter numerator:", "Numerator")
If oNum = "" Then
MsgBox "Numerator cannot be left blank.", , _
"Illogical expression"
End If
Loop Until oNum <> ""
Do
oDen = InputBox("Enter denominator:", "Denominator")
If oDen = "0" Or oDen = "" Then
MsgBox "Denominator cannot be zero or left blank.", , _
"Illogical expression"
End If
Loop While oDen = "0" Or oDen = ""
If oDen <> "" Then
ActiveDocument.Fields.Add Range:=Selection.Range, _
Type:=wdFieldEmpty, _
Text:="EQ \f(" & oNum & ", " & oDen & " )", _
PreserveFormatting:=False
End If
End Sub
Sub InsertFraction()
Dim Expr As String
Dim Numerator As String
Dim Denominator As String
Dim NewSlashChar As String
Dim SlashPos As Integer
Dim bInvalid As Boolean
NewSlashChar = ChrW(&H2044)
Do
bInvalid = False
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
bInvalid = True
MsgBox "Format must be numerator/denominator" _
& " (e.g., 3/4, a/b, etc.)." _
& " Please try again.", , "Format Error"
End If
Numerator = Left(Expr, SlashPos - 1)
Denominator = Right(Expr, Len(Expr) - SlashPos)
If Denominator = "0" Then
bInvalid = True
If MsgBox("The denominator is a null value." _
& " Do you want to override?", vbYesNo, _
"Illogical Expression") = vbYes Then
bInvalid = False
End If
End If
Loop While bInvalid
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 Sub

Signature
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
> Seems like it included a macro for creating fractions; perhaps you
> have that stashed somewhere?
[quoted text clipped - 35 lines]
>>>>>>>> formatting as [quoted text clipped - 14 lines] Thanks,
>>>>>>>> Ashish
Charles Kenyon - 18 Dec 2005 18:25 GMT
That goes in my archives. Thank you.

Signature
Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
> Yes I have some fraction macros and some of the images. I just don't
> remember how I had it put together. Here is a couple of macros. The
[quoted text clipped - 107 lines]
>>>>>>>>> formatting as [quoted text clipped - 14 lines] Thanks,
>>>>>>>>> Ashish