Re: How to add Fractions along with their formatting as AutoText in a template



That goes in my archives. Thank you.
--
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.

"Greg Maxey" <gmaxey@xxxxxxxxxxxxxxxxxxx> wrote in message
news:Oi8LZ%23$AGHA.1028@xxxxxxxxxxxxxxxxxxxxxxx
> 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
>
> --
> Greg Maxey/Word MVP
> See:
> http://gregmaxey.mvps.org/word_tips.htm
> For some helpful tips using Word.
>
> Suzanne S. Barnhill wrote:
>> Seems like it included a macro for creating fractions; perhaps you
>> have that stashed somewhere?
>>
>>
>> "Greg Maxey" <gmaxey@xxxxxxxxxxxxxxxxxxx> wrote in message
>> news:%23o8F4B$AGHA.2356@xxxxxxxxxxxxxxxxxxxxxxx
>>> All, due to some carelessness, I have inadvertently deleted my
>>> formatted fractions tips page. I don't know when or how it happened
>>> but since I backup over backups I have not only made the mistake,
>>> but copied it to the backup file. I am afraid that page is now in
>>> the dustbin of history. I don't even remember exactly its content
>>> so I won't be attempting to recreate it anytime soon. Sorry.
>>>
>>>
>>> --
>>> Greg Maxey/Word MVP
>>> See:
>>> http://gregmaxey.mvps.org/word_tips.htm
>>> For some helpful tips using Word.
>>>
>>> Ashish via OfficeKB.com wrote:
>>>> i am not able to access site :
>>>> http://gregmaxey.mvps.org/Formatted_Fractions.htm
>>>> But i want to know i what Application event can i get to know to
>>>> replace AutoText entry when it is entered with that of the one which
>>>> i need to insert programmatically
>>>>
>>>>
>>>>
>>>> Graham Mayor wrote:
>>>>> And autoCORRECT may be the better option than autoTEXT if the
>>>>> behaviour is to echo Word's default fraction options?
>>>>> Again the formatted fractions made up of multiple characters may be
>>>>> applied in this manner.
>>>>>
>>>>> For alternative fraction creation methods to that suggested by
>>>>> Suzanne see:
>>>>>
>>>>> http://www.gmayor.com/createfraction.htm
>>>>> or
>>>>> http://gregmaxey.mvps.org/Formatted_Fractions.htm
>>>>>
>>>>>> By doing what? If you use the built-in fractions, they are font
>>>>>> characters and require no special formatting; they will conform to
>>>>> [quoted text clipped - 25 lines]
>>>>>>>>> formatting as [quoted text clipped - 14 lines] Thanks,
>>>>>>>>> Ashish
>
>


.



Relevant Pages

  • Re: How to add Fractions along with their formatting as AutoText in a template
    ... Yes I have some fraction macros and some of the images. ... Dim oNum As String ... Dim bInvalid As Boolean ...
    (microsoft.public.word.customization.menustoolbars)
  • Re: evaluating simple mathematical expressions
    ... >> What is the simplest way of converting a fractional string like ... > Function FracToDec(ByVal Fraction As String) As Double ... > Dim Blank As Integer ... > Dim Slash As Integer ...
    (microsoft.public.vb.general.discussion)
  • Re: Find AND Fix Fractions
    ... Sub FindFixFractions() ... Dim rng As Word.Range ... Dim pStr As String ... the end of this note] but the fraction needs to be selected in order ...
    (microsoft.public.word.vba.beginners)
  • Re: accept fractions from textbox
    ... Function FracToDec(ByVal Fraction As String) As Double ... Dim myValue As Double ... I am having trouble getting this to work in Excel 2007; ...
    (microsoft.public.excel.programming)
  • Re: evaluating simple mathematical expressions
    ... > What is the simplest way of converting a fractional string like ... Function FracToDec(ByVal Fraction As String) As Double ... Dim Blank As Integer ... Dim Slash As Integer ...
    (microsoft.public.vb.general.discussion)

Loading