Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro for formatting ANY fraction you enter (2000)

    Thanks for sharing this! As a small addition, one might use
    .TypeText ChrW(&H2044)
    in place of the line
    .TypeText "/"

    U+2044 is the fraction slash, which looks much nicer than the regular slash, and should be available in the fonts commonly used in Word (Arial, TNR, Courier New ...).

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> Klaus

  2. #2
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    London, United Kingdom
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro for formatting ANY fraction you enter (2000)

    I have people asking me how to do fractions every week and it has been a pain. Your place in heaven is assured.

    Thanks

  3. #3
    Star Lounger
    Join Date
    Jun 2002
    Posts
    98
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Macro for formatting ANY fraction you enter (2000)

    <P ID="edit" class=small>(Edited by Phil Rabichow on 02-Feb-04 13:35. if you have Option Explicit set in your VBE, you had to add the following two lines somewhere near the beginning:

    Dim fraction As String, slashPosition As String
    Dim preSlash As String, postSlash As String
    )</P>The latest newsletter discussed formatting text with sub/superscript to make nicer looking fractions. Here's a macro to automate that process for any combination of numbers needed:

    Sub EnterFraction()
    'Add this macro to your Normal.dot
    'Assign a keystroke like Alt-/ to this macro (Tools...Customize...Keyboard)

    'Prompt user for the text to format as a fraction
    fraction = InputBox("Enter fraction text (ex: 1/2, 5/32)")
    'Find the position of the slash in the text
    slashPosition = InStr(fraction, "/")
    'Quit if no slash in the text
    If slashPosition = 0 Then Exit Sub

    preSlash = Left(fraction, slashPosition - 1)
    postSlash = Right(fraction, Len(fraction) - slashPosition)
    With Selection
    'Type text before the slash as superscript
    .Font.Superscript = True
    .TypeText preSlash

    'Type the slash as normal text
    .Font.Superscript = False
    .TypeText "/"

    'Format text after the slash
    .Font.Subscript = True
    .TypeText postSlash

    'Continue with font back to normal
    .Font.Subscript = False
    End With

    End Sub
    __________________________________________________ ____
    <img src=/S/nun.gif border=0 alt=nun width=20 height=20> Sister Dory
    Our Lady of Perpetual Help, Holstein Falls, Wisconsin, USA

  4. #4
    Star Lounger
    Join Date
    Dec 2003
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro for formatting ANY fraction you enter (2000)

    Maybe this is obvious to everyone else, but why is unicode ChrW, and nor ChrU?

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro for formatting ANY fraction you enter (2000)

    The "W" stands for "Wide". Since Unicode characters take up two bytes instead of one (as for ASCII/ANSI), they are called "wide characters."

Posting Permissions

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