Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Jan 2002
    Location
    NSW Australia
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Fractions in Word (All)

    Thanks to Woody for his fantastic newsletters, which have saved me more than once since subscribing about 5 years ago. I was surprised to find that his latest message about fractions in Word failed to tell readers of the excellent "InsertObjectMicrosoft Equation" method of creating fractions in Office applications.
    If you go this way, you can create any kind of fraction without too much fuss. Give it try! I hope this gets to Woody.

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Fractions in Word (All)

    I don't remember where I got these macros from, but apparently I didn't write it down at the time. They were posted in a tips group, so I'm sure the author doesn't mind. My guess is that one was written by Pieter Janssens & the other by Ed Weber.

    <pre>Sub Fraction()
    '
    ' Fraction Macro
    ' Macro created 12/1/01
    ' Changes fraction to superscript/subscript
    ' Adds space after fraction to continue typing
    ' Works with multi-digit numerator & denominator
    ' Must type two spaces before proper fraction
    '
    Dim OrigFrac As String
    Dim Numerator As String, Denominator As String
    Dim NewSlashChar As String
    Dim SlashPos As Integer

    NewSlashChar = "/"

    Selection.MoveLeft Unit:=wdWord, Count:=3, Extend:=wdExtend
    OrigFrac = Selection
    SlashPos = InStr(OrigFrac, "/")
    Numerator = Left(OrigFrac, SlashPos - 1)
    Denominator = Right(OrigFrac, Len(OrigFrac) - SlashPos)
    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

    Selection.MoveLeft Unit:=wdWord, Count:=3
    Selection.TypeBackspace

    Selection.EndKey Unit:=wdLine
    Selection.TypeText Text:=" "
    Selection.Font.Subscript = False
    End Sub</pre>

    <pre>Sub FractionsInputBox()
    '
    ' FractionsInputBox Macro
    ' Macro created 12/2/01 by
    '
    Dim Prompt, Heading
    Prompt = "Please enter the Numerator....."
    Heading = InputBox$(Prompt, "Peter's Fractions - Numerator")
    With Selection.Font
    Selection.Font.Size = 12
    Selection.Font.Superscript = True
    Selection.TypeText Text:=Heading
    Selection.Font.Superscript = False
    Selection.TypeText Text:="/"
    End With

    Prompt = "Please enter the Denominator....."
    Heading = InputBox$(Prompt, "Peter's Fractions - Denominator")
    With Selection.Font
    Selection.Font.Size = 12
    Selection.Font.Subscript = True
    Selection.TypeText Text:=Heading
    End With

    Selection.Find.ClearFormatting
    With Selection.Find
    .Text = "" 'Line 19
    .Replacement.Text = " "
    .Forward = False
    .Wrap = wdFindAsk
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.EndKey Unit:=wdLine
    Selection.Font.Subscript = False
    Selection.TypeText Text:=" "
    End Sub</pre>

    Hope this helps,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •